![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
| Hi all,,, I just wanted to inquire about the serial communication in Atmel 89c51, In fact I wrote a simple program to communicate with a GPS module, and then display the data on a LCD, the longitude is ., the latitude is , the altitude is ., blah blah blah, The weird action is I forgot to connect the MC with the module, and guess what ?!! I found the LCD display the longitude is .., the latitude is .., the altitude is ., blah blah blah , So? How that happened? I think the MC couldn't pass the serial communication part if it didn't get any data at the Rx pin, Am I right or what?!! Please somebody help me ! | |
| |
| | #2 |
|
It sounds like there's a problem with your code. If you use the flags RI and TI you should be able to make it wait to receive something before it displays.
| |
| |
| | #3 | |
| Quote:
| ||
| |
| | #4 |
|
If you post the relevant sections of code we can give you more help.
| |
| |
| | #5 |
| Dear bmcculla here is the code and thx for your support Mov A, # 40 H ; Transfer @ Lcall Trans Mov A, #40 H ; Transfer @ Lcall Trans Mov A, # 45H ; Transfer E Lcall Trans Mov A, #71H ; Transfer q Lcall Trans Mov A, # 00H ; Transfer r output rate Lcall Trans Mov A, # 34 H ; Transfer checksum Lcall Trans Mov A, # 0D H ; Transfer < SR > Lcall Trans Mov A, # 0A H ; Transfer < LF> Lcall Trans Mov R2, #96 ; Load counter Mov R0, # 30 H ; Load pointer R0 =30 RAM address Nina: JNB RI, Nina ; Wait for char. to come in Mov A, SBUF ; Save incoming byte in A Mov @R0, A ; Copy A to RAM location R0 points to INC R0 ; Increment R0 pointer CLR RI ; Get ready to receive next byte DJNZ R2, Nina ; decrement and jump to Nina if it is not Zero Mov A, #38 H ; Init LCD 2 lines, 5*7 Matrix LCALL Command ; Issue command LCALL Sarah ; Mov A, # 'D' ; Display letter D LCALL Romeo Mov A, # ' a' LCALL Romeo Mov A, #'t' LCALL Romeo Mov A, #' e' LCALL Romeo LCALL Is Mov R2, #09 ; Load counter Mov R0, #35 H ; Load pointer R0= 35H RAM address LCALL Juliet LCALL Sarah Mov A, #'T' ; Display letter T LCALL Romeo Mov A, #'i' LCALL Romeo Mov A, #'m' LCALL Romeo Mov A, #'e' LCALL Romeo LCALL Is Mov R2, #09 ; Load counter Mov R0, 3E H ; Load pointer R0 = 3E RAM address LCALL Juliet LCALL Sarah Mov A, #'L' ; Display letter L LCALL Romeo Mov A, #'a' LCALL Romeo Mov A, #'t' LCALL Romeo Mov A, #'i' LCALL Romeo Mov A, #'t' LCALL Romeo Mov A, #'u' LCALL Romeo Mov A, #'d' LCALL Romeo Mov A, #'e' LCALL Romeo LCALL Is Mov R2, #13 ; Load counter Mov R0, #47H ; Load pointer R0= 47 RAM address LCALL Juliet LCALL Sarah Mov A, #'L' LCALL Romeo Mov A, #'o' LCALL Romeo Mov A, #'n' LCALL Romeo Mov A, #'g' LCALL Romeo Mov A, #'i' LCALL Romeo Mov A, #'t' LCALL Romeo Mov A, #'u' LCALL Romeo Mov A, #'d' LCALL Romeo Mov A, #'e' LCALL Romeo LCALL Is Mov R2,# 14 ;Load counter Mov R0, #54H ; Load pointer LCALL Juliet LCALL Sarah Mov A, #'H' LCALL Romeo Mov A, #'e' LCALL Romeo Mov A, #'i' LCALL Romeo Mov A, #'g' LCALL Romeo Mov A, #'h' LCALL Romeo Mov A, #'t' LCALL Romeo LCALL Is Mov R2,# 09 ;Load counter Mov R0, #62H ; Load pointer LCALL Juliet LCALL Sarah Mov A, #'S' LCALL Romeo Mov A, #'p' LCALL Romeo Mov A, #'e' LCALL Romeo Mov A, #'e' LCALL Romeo Mov A, #'d' LCALL Romeo LCALL Is Mov R2,# 05 ;Load counter Mov R0, #6BH ; Load pointer LCALL Juliet LJMP Again; Sarah: Mov A, #0E H ; LCD on, cursor on LCALL Command ; issue command Mov A, #01 H ; Clear LCD command LCALL Command ; issue command Mov A, #06 H ; Shift cursor right LCALL Command ; issue command Mov A, #80 H ; Force cursor at the beginning of the 1st ;line LCALL Command ; issue command RET Is: Mov A, #' ' LCALL Romeo Mov A, #'i' LCALL Romeo Mov A, #'s' LCALL Romeo Mov A, #':' LCALL Romeo Mov A, # 40 H ; Force cursor at the beginning of the2nd line LCALL Command RET Juliet: Mov A, @R0 ; Move contents of RAM location @R0 to A LCALL Romeo INC R0 ; increment pointer DJNZ R2, Juliet ; LCALL LCD_Delay RET Command: ACALL Ready Mov P1, A CLR P2.5 CLR P2.6 SETB P2.7 CLR P2.7 RET Romeo: ACALL Ready Mov P1, A SETB P2.5 CLR P2.6 SETB P2.7 CLR P2.7 RET Ready: SETB P1.7 CLR P2.5 SETB P2.6 Back: CLR P2.7 SETB P2.7 JB P1.7, Back RET Delay:Mov R4,#230 Here:Nop Nop DJNZ R4, Here RET DDelay: Mov R5, #02 Delayy: Mov R4, # 230 Hero: Nop Nop DJNZ R4, Hero DJNZ R5, Delayy RET LCD_Delay: Mov R4, #07 Pet: Mov R5, #255 Mag: Mov R6, #255 Hera: NOP NOP DJNZ R6, Hera DJNZ R5, Mag DJNZ R4, Pet RET Delai: Mov R4, #114 Herb: NOP NOP DJNZ R4, Herb RET Thx again | |
| |
| | #6 |
| iam sorry here is the Trans subroutine Trans: Mov SBUF, A ; Load SBUF Robert: JNB TI, Robert ; Wait for last bit to transfer CLR TI ; Get ready for next bit RET | |
| |
| | #7 |
|
Try clearing RI before the receive segment. It's very hard to understand your code. It's a good idea to name your labels names that relate to what they do. It makes it easier for some one else to understand what the label is for. It also helps if you comment segments of code with information about what the segment does. If you rename all your people labels and put a short comment about what each subroutine does it will be much easier to help you. | |
| |
| | #8 |
|
the code seems to be correct but may be the delay that you are giving is small enough.
| |
| |
| | #9 | |
| Quote:
Code: Trans: jnb TI,Trans
clr TI
mov SBUF,A
ret
Last edited by Papabravo; 1st December 2006 at 10:07 PM. | ||
| |
| | #10 |
|
Hi Dear I`m also working on a project in which i have to display GPS data on an LCD.but uptil now i`m unable to do this.can u help me ??? | |
| |
|
| Tags |
| 89c51, atmel, communication, serial |
| Thread Tools | |
| Display Modes | |
| |