Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Issue successfully resolved

???
03/08/04 19:56
Read: times


 
#66287 - RE: I think this should be okay
Responding to: ???'s previous message
I paid a little visit to your site to view the updated code, and I was a little disappointed that it does not show any signs of improvement after all the advice that was given to you in this thread.

Your main loop:

LOOP:
mov sbuf,@r0 ;move the content pointed by r0 to sbuf for transmission to PC
nop ;just to pause
SJMP LOOP

- You definitely do not want to do this. This will cause what is at @r0 to be written to sbuf endlessly, and much, much too quickly. This is essentially the same as why your original code was never going to work. Also, WHY the nop? What good is that going to do you? The "pause" it will give you is 100 times shorter than the time it takes for a character to be transmitted at 9600 baud!

You need:

mov sbuf,@r0
LOOP:
SJMP LOOP



Then your isr:

SERIAL: JNB TI,$
CLR TI
cjne r0,#42h,next
mov r0,#40h
sjmp out
next:inc r0
out:mov sbuf,@r0
RETI

SERIAL: JNB TI,$

- You have not enabled your receiver, so the only thing leading to a serial interrupt will be TI. So every time you enter the isr, you will find TI set. Period. There is no sense in testing it, let alone starting a tight loop to poll it (which as I have pointed out before is a dirty, primitive technique anyway). As I pointed out before also, it makes no sense to do a combination of interrupt and polling the flag which caused the interrupt. So did you read that? Did you understand it?

cjne r0,#42h,next
mov r0,#40h
sjmp out
next:inc r0
out:mov sbuf,@r0
RETI

- Can you tell when this sequence will stop once started? Well: never. It will endlessly start to transmit the characters without ever stopping. You don't want that, you want it to happen once, and then the transmissions must stop. So:

inc r0
cjne r0,#43h,out
reti

out:
mov sbuf,@r0
reti



The code you showed in your "is this okay" post made me think you were somewhat on the right track, but this is a big step back. You are staring at the code too much and not trying to understand what is really happening. Throw your simulator in the bin, and start using your head. It is better.
Another question relating to your seeing only junk characters in the terminal emulator: What frequency crystal are you using with your controller?


List of 61 messages in thread
TopicAuthorDate
What is wrong in my serial comm prog            01/01/70 00:00      
   RE: What is wrong in my serial comm prog            01/01/70 00:00      
      RE: What is wrong in my serial comm prog            01/01/70 00:00      
         RE: What is wrong in my serial comm prog            01/01/70 00:00      
         RE: What is wrong in my serial comm prog            01/01/70 00:00      
            RE: What is wrong in my serial comm prog            01/01/70 00:00      
            You mean the ISR?            01/01/70 00:00      
   RE: What is wrong in my serial comm prog            01/01/70 00:00      
   RE: What is wrong in my serial comm prog            01/01/70 00:00      
      Deepak disappeared            01/01/70 00:00      
         RE: Deepak (dis)appeared            01/01/70 00:00      
            RE: Deepak (dis)appeared            01/01/70 00:00      
               The problem continues            01/01/70 00:00      
                  What I have understood till now            01/01/70 00:00      
                     RE: What I have understood till now            01/01/70 00:00      
                        RE: What I have understood till now            01/01/70 00:00      
                           Hans van Pelt & patrick de groote            01/01/70 00:00      
                           RE: What I have understood till now            01/01/70 00:00      
                           What is the problem now            01/01/70 00:00      
                           What is the problem now            01/01/70 00:00      
                              RE: What is the problem now            01/01/70 00:00      
                        Is this okay            01/01/70 00:00      
                           RE: Is this okay            01/01/70 00:00      
                              RE: Is this okay            01/01/70 00:00      
                              RE: Is this okay            01/01/70 00:00      
                                 RE: Is this okay            01/01/70 00:00      
                                    re:is this okay            01/01/70 00:00      
                                       RE: re:is this okay            01/01/70 00:00      
                                       RE: re:is this okay            01/01/70 00:00      
                                          I think this should be okay            01/01/70 00:00      
                                             RE: I think this should be okay            01/01/70 00:00      
                                                RE: I think this should be okay            01/01/70 00:00      
                                                   RE: I think this should be okay            01/01/70 00:00      
                                                   RE: I think this should be okay            01/01/70 00:00      
                                                      RE: I think this should be okay            01/01/70 00:00      
                                                      RE: I think this should be okay            01/01/70 00:00      
                                                         RE: I think this should be okay            01/01/70 00:00      
                                                            I will wait for my victory            01/01/70 00:00      
                                                               RE: I will wait for my victory            01/01/70 00:00      
                                                                  RE: I will wait for my victory            01/01/70 00:00      
                                                                     RE: I will wait for my victory            01/01/70 00:00      
                                                                     RE: I will wait for my victory            01/01/70 00:00      
                                                                        RE: I will wait for my victory            01/01/70 00:00      
                                                                           RE: your hardware            01/01/70 00:00      
                                                                        RE: I will wait for my victory            01/01/70 00:00      
                                                                     RE: I will wait for my victory            01/01/70 00:00      
                                                               RE: I will wait for my victory            01/01/70 00:00      
                                                                  RE: I will wait for my victory            01/01/70 00:00      
                                                                     I will be the victor soon            01/01/70 00:00      
                                                                        Protect dptr            01/01/70 00:00      
                                                                           RE: Protect dptr            01/01/70 00:00      
                                                                        RE: I will be the victor soon            01/01/70 00:00      
                                                                     RE: I will wait for my victory            01/01/70 00:00      
                                                                        RE: I will wait for my victory            01/01/70 00:00      
                                 RE: Is this okay            01/01/70 00:00      
                                    RE: Is this okay            01/01/70 00:00      
                                       RE: Is this okay            01/01/70 00:00      
                                    RE: Is this okay            01/01/70 00:00      
                                       RE: Is this okay            01/01/70 00:00      
                                       RE: Is this okay            01/01/70 00:00      
   close this discussion            01/01/70 00:00      

Back to Subject List