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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/25/05 23:11
Read: times


 
#95922 - The logic seems good
Responding to: ???'s previous message

Adam, your logic seems sound. But you give us no information where you think it is failing. If you can post the code you are using, that might give us a better insight into what the issue is. In the meantime, check a few things -

1/ try your code without interrupts - load the timer, set it to run then sit in a loop waiting for the overflow bit to be set. This removes the complication of interrupts if you're new to this. It will also prove your basic logic.

2/ if you get the above working, then its back to trying interrupts. Firstly just have the interrupt code toggle the port pin - keep it simple first time up. Remember you have to enable both the EA bit and the timer interrupt enable bit in the IE register. Another gotcha is declaring a local variable in an interrupt routine - locals are only created when entering the routine and destroyed when you leave - no good for storing a flag! You must declare the flag variable as 'static' - that way the variable is allocated some ram and is not trashed.

For example:
static char flag_var=0;

I think I've covered the usual traps for young players! Hope this helps.



List of 30 messages in thread
TopicAuthorDate
General Pulse Width Modulation on 8051            01/01/70 00:00      
   The logic seems good            01/01/70 00:00      
      How to post code            01/01/70 00:00      
      Code I'm using            01/01/70 00:00      
         Problem lies with SDCC and PSW handling.            01/01/70 00:00      
            similar "issue" with Keil?            01/01/70 00:00      
            PSW not touched in recent version            01/01/70 00:00      
               Old SDCC (ver ??) vs New SDCC (ver 2.50)            01/01/70 00:00      
                  strange            01/01/70 00:00      
                     not strange, sorry            01/01/70 00:00      
                        Still no good            01/01/70 00:00      
                           Still not strange            01/01/70 00:00      
   Alternative method            01/01/70 00:00      
   65536, not 65535            01/01/70 00:00      
      Caught that errror            01/01/70 00:00      
         why not use the PCA, it is made for this            01/01/70 00:00      
            No PCA available            01/01/70 00:00      
               slim PICkins            01/01/70 00:00      
               go ahead, spend $7            01/01/70 00:00      
                  Why not read 8051 stuff?            01/01/70 00:00      
                     Excellent - Thanks            01/01/70 00:00      
                  Atmel Flip            01/01/70 00:00      
                     MAX232(equivalent)            01/01/70 00:00      
                        Another Option            01/01/70 00:00      
                     level convertor            01/01/70 00:00      
                        aka "Transceiver"            01/01/70 00:00      
         JSIM.EXE is all you need and it FREE.            01/01/70 00:00      
   Still not strange            01/01/70 00:00      
   Follow Up to the original post            01/01/70 00:00      
      Dumb and dumberrer            01/01/70 00:00      

Back to Subject List