We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hy, is there any possibilities to determine the actual baudrate with the C167? We are just developing the second version of our download software from PC to uC which should be downward compatible with the first one. This first one works with a baud rate of 9,6kBaud, the new one eith 56k. In the infineon bootstrap loader, there is an automatic baud rate detection. How do they do it? Thanks HARALD
The following code has worked for me. I believe the '166 does something similar: 1) Monitor Rx pin for falling edge (start bit) 2) Start timer (T6) 3) Monitor Rx pin for rising edge (stop bit) 4) Read timer 5) Calculate baud rate
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
"3) Monitor Rx pin for rising edge (stop bit)" How do you know that it's the rising edge of the Stop Bit, rather than any other rising edge between bits within the character?
Neil, The '166 family always expects the first byte transmitted to be an 0x00, 1 start bit, 8 data bits, no parity and 1 stop bit. Anything else, including power-up glitches will screw up the baud rate detection. Best luck Scott