This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

XC16x Autobaud detection unit

Hi,

can somebody help me with the right setup for
using the the autobaud detection unit the right way.
I have problems with the generally steps to propperly setting up the ASC.
Also a more detailed description of the module as it is in the manuals is welcome.

Thanks Stefan

  • Stefan,
    If you're talking about the auto-baud in the bootstrap, it uses a free-running timer (#6 I believe). The Rx input is monitored until it drops using a tight loop. Then the timer is started and the Rx input is monitored until it goes high. The timer is read and the baud rate divisor is calculated. It requires the first byte received to be the following:
    1 start bit
    8 data bits = 0x00
    1 stop bit
    no parity.

    The actual assembly code for the 167CR series was given in a book on the '166 by ST. This is an early version of code I included in my boot system to emulate the bootstrap mode, allowing debugging on a production system. I don't have a copy of the latest available since I'm not at work.

    	Fake_Bootstrap	PROC NEAR
    
    	MOV	CP, #0FA00h			;Init to reset values
    	MOV	STKUN, #0FFFFh			;Leave Ext bus controls alone (for now)
    	MOV	STKOV, #0000h
    	MOV	SP, #0FA40h
    	MOV	STKUN, #0FA40h
    	MOV	STKOV, #0FA0Ch
    	MOV	DPP0, #0000
    	MOV	DPP1, #0001
    	MOV	DPP2, #0002
    	MOV	DPP3, #0003
    
    	MOV	T6CON, #0000			;Init baud rate detector
    	MOV	T6, #0000
    
    	BCLR	DP3.11				;Rx = Input
    BTSTRP1:					;while ( ! ~Rx_Port )	// Start bit detect
    	JB	P3.11, BTSTRP1			;  continue;
    
    	BSET	T6R				;Baud timer = Running
    BTSTRP2:					;while ( ~Rx_Port )	// Stop bit detect
    	JNB	P3.11, BTSTRP2			;  continue;
    
    	BCLR	T6R				;Baud timer = Stopped
    	MOV	R1, #36
    	MOV	MDL, T6				;BRG = ((T6/36)) / 2 - 1
    	DIVU	R1
    	MOV	R2, MDL
    	ROR	R2, #1
    	JMPR	cc_C, BTSTRP3			;  round result
    
    	SUB	R2, #0001
    BTSTRP3:
    	MOV	S0BG, R2			;Init serial port
    	BSET	P3.10
    	BSET	DP3.10
    	MOV	S0RIC, #0000
    	MOV	S0CON, #8011h			;Enable
    
    	MOV	S0TBUF, #00C5h			;Transmit Ack code for '167
    	MOV	R0, #0FA40h			;BYTE *p_Byte = bootstrap_Base;
    BTSTRP4:					;do {
    	JNB	S0RIR, BTSTRP4			;  while ( ! rx_Byte )
    						;    continue;
    	MOVB	[R0], S0RBUF			;    *p_Byte++ = rx_Byte;
    	BCLR	S0RIR
    	CMPI1	R0, #0FA60h
    	JMPR	cc_ULT, BTSTRP4			;} while ( p_Byte < bootstrap_Top );
    
    	JMPA	cc_UC, 0FA40h			;goto( bootstrap_Base );
    
    	Fake_Bootstrap	ENDP
    
    Best
    Scott

  • Hi Scott,

    thanks for this, but the autobaud detection in XC16x derivatives seems to have a little bit other function.
    A timer should be used, but you can select nine different baud rates before you start the detection.
    I found a good description with the APNOTE DS1 (June 2001) from Infineon for the
    C161U and C165UTAH.
    This show the way more detailed and uses timer 3.
    I will adapt this and your code hint.

    Stefan