??? 03/07/12 17:22 Read: times |
#186478 - Serial coms, bytes not matching in serial capture |
Hi, I'm currently setting up my project to send info over serial port. I have run into a problem I am having difficulty resolving. I am using MCU C8051F020 Silabs MCU and Realterm (serial capture).
What I want to do is send 25 bytes of code over the serial port and be displayed in Realterm on PC. My issue is when I hit run in the IDE, I get bytes present on the PC but they are not matching the bytes I have written in my code. I assumed it was a baud rate issue, but I have used an oscilliscope and looped the value 'A' to be constantly written so that I could test it and oscilliscope is set at .1mS/div and I am getting 9600bps and Realterm is set for 9600bps also. With sending only one byte over to Realterm it can reporoduce that no problem with no errors, but as soon as i introduce the 25 bytes it prints out 'garbage' (below) ~7E 00 01 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 ,2C ~7E 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 (expected 25 bytes below) 7EH,00H,00H,00H,01H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,01H I have calculated the baud rate as per the datasheet and it is correct as far as i can see (unless datasheet is incorrect) Thanks Dave ORG 100H START: MOV SP,#4FH ;START STACK @ 50H MOV WDTCN,#0DEH ;DISABLE WATCHDOG MOV WDTCN,#0ADH LCALL LCD_INIT ;INITILIZE LCD DISPLAY ;LCALL CONFIGURE_INTERRUPT ;SETS UP INTERRUPTS FPR SERIAL COMMS LCALL CONFIGURE_PORTS ;CALLS SUBROUTINE TO INITILIZE PORTS LCALL CONFIGURE_UART1 ;CALLS SUBROUTINE TO INITILIZE UART ON CROSSBAR LCALL REQUEST_CONNECTION ;CALLS REQUEST CONNECTION TO FINGERPRINT MODULE LCALL MAIN MAIN: LCALL DISPLAY_6 ;CALLS DISPLAY 'PRESS BUTTON TO SCAN FINGER' LCALL PUSHBUTTONS ;CALL PUSHBUTTON SUBROUTINE THATS CHECKS TO SEE IF A BUTTON IS PUSHED LJMP MAIN ;======================================================================================== ;HERE THE PORTS ARE CONFIGURED FOR THE PROGRAMME, CROSSBAR REGISTERS ARE SETUP TO ENABLE UART0. ;EACH PORT IS SETUP AS REQUIRED TO OPERATE, ;======================================================================================== CONFIGURE_PORTS: MOV OSCXCN,#01100111B ;SET OSCILLATOR TO 22.1184MHz XTLVLD_WAIT: ;POLL FOR XTLVLD TO BE 1, XTLVLD NEEDS TO BE 1 SO THAT THE EX.OSCILLATOR IS STABLE MOV A,OSCXCN ;MOV EX.OSCILLATOR TO ACCUMULATOR SO THAT BIT 7 CAN BE DETERMINED IF IT IS SET OR NOT ANL A, #80h ;LOGIC 'AND' ACC WITH 10000000B TO CHECK AND SEE IF BIT 7 IS SET JZ XTLVLD_WAIT ;LOOP AROUND UNTIL ACC IS = 0 MOV OSCICN, #88h ;DISABLE INTERNAL OSCILLATOR MOV P0MDOUT,#00000101B ;PUSHPULL FOR TX P0.2 MOV P1MDOUT,#00000000B ;ALL 0 P1 NOT IN USE MOV P2MDOUT, #11111100B ;PUSHPULL FOR LCD DISPLAY MOV P74OUT,#00001000B ;SET PUSH/PULL MODE FOR P5.7-5.4 (THE LEDS) MOV P4,#0FFH ;PORT 4 IS SET UP AS AN INPUT PORT MOV P5,#0FH ;PORT 5 BITS 0-3 ARE ALSO PROGRAMMED AS ;INPUTS. LEDS ARE OFF MOV xbr1,#00h ;NOT IN USE MOV xbr2,#44h ;ENABLE CROSSBAR & UART1 MOV xbr0,#04h ;THIS SELECTS UART0 WHICH MAKES UART1 P0.2 P0.3 RET ;============================================================================================== ;HERE IS THE CONFIGURATION OF THE UART, WHICH WILL BE SET @ 9600 BPS, IT WILL BE CONTROLLED BY TIMER1 ;UART0 IS INITIALIZED AND SET FOR 8 BIT VARIABLE BAUD RATE. ;============================================================================================== CONFIGURE_UART1: ;if you want 9600 baud then you don't want to set bit 4 (T1M) ;on the next line ! Doing so will give 230400 baud. ORL CKCON,#00H ;TIMER1 USES SYSTEM CLOCK AT 22.1184MHz MOV TMOD,#20H ;TIMER1 MODE 1 8-BIT AUTORELOAD MOV TH1, #0FAH MOV TL1, #0FAH ;BAUD RATE 9600 SETB TR1 ;START TIMER1 MOV PCON, #00H ;THIS WILL DIVIDE BY 2 AND GIVE 9600 BAUD RATE MOV SCON1,#01010000B;UART1 MODE 1, 8-BIT VARIABLE BAUD RATE, RX ENABLED RET ;=============================================================================================== ;THIS SUBROUTINE WILL WRITE EACH BYTE FROM PACKET BEING SENT OVER THE SERIAL PORT THROUGH THE SBUF. ;THE ACCUMULATOR HOLDS THE VALUE POINTED AT BY THE DPTR ;IT WILL CONTINUE THIS LOOP UNTIL TI BIT IS SET '1' ;=============================================================================================== WRITE_SERIAL: MOV SBUF1,A ;WRITE VALUE IN ACC TO SBUF TEST_TI1: MOV A,SCON1 ANL A,#02H ;TEST TI1 FLAG JZ TEST_TI1 MOV A,SCON1 ANL A,#0FDH ;CLEAR TI1 MOV SCON1,A ;MOV A, #041H ;THESE 2 LINES ARE HERE FOR TESTING PURPOSES, COMMENT OUT FOR EXECUTION ;JMP WRITE_SERIAL ;OF CODE IN FULL OPERATION. RET ;============================================================================================= ;THIS SUBROUTINE TAKES A PACKET AND MOVES EACH VALUE ONE BY ONE TO THE ACCUMULATOR FROM THE DPTR, ;WHICH IS THEN SENT TO WRITE_SERIAL ROUTINE. ;============================================================================================= WRITE_TABLE_SERIAL: NEXT_BYTE: MOVC A, @A+DPTR ;LET ACC = THE POINT THAT VALUE OF ACC POINTS TO IN DATAPOINTER LCALL WRITE_SERIAL;CALL ROUTINE INC DPTR ;INCREMENT DATAPOINTER TO WRITE NEXT BYTE OF CODE DJNZ R0,NEXT_BYTE ;LOOP R0 IF R0 =! 0 RET REQUEST_CONN: DB 7EH,00H,00H,00H,01H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,01H |
Topic | Author | Date |
Serial coms, bytes not matching in serial capture | 01/01/70 00:00 | |
Couple of things at first glance... | 01/01/70 00:00 | |
Response | 01/01/70 00:00 | |
OK | 01/01/70 00:00 | |
what does the instruction spell out | 01/01/70 00:00 | |
Instruction says | 01/01/70 00:00 | |
Got it | 01/01/70 00:00 | |
have a good read | 01/01/70 00:00 | |
Nitgen FIM5360 module | 01/01/70 00:00 | |
Not familiar with the module... | 01/01/70 00:00 | |
Boot up time... | 01/01/70 00:00 | |
Response | 01/01/70 00:00 | |
Isn't boot time always time from reset or time from power-on | 01/01/70 00:00 | |
Ok | 01/01/70 00:00 | |
SCON1... | 01/01/70 00:00 | |
Jumping from RET to Jump Start | 01/01/70 00:00 | |
Please Ignore last post, issue resolved | 01/01/70 00:00 |