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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Hal Albach
01/12/13 15:10
Read: 1053 times
Seminole, Florida

#189142 - To avoid problems
Responding to: Jai Nair's previous message
Your CLEAR: function sets each bit of an output port sequentially and could cause problems. The 8051 ports are all READ-MODIFY-WRITE which means that when you write to the port all the PINS, not the latches, are read, then changed, then written back to the port latches. Problems arise when you modify multiple bits individually one after another on the same port. For example, you SETB L4 (which is port pin P1.7) and because of loading the port pin might be slow to rise to Vcc. Before it has a chance to rise very much the next instruction (SETB L5) will set port pin P1.6 to 1, but first all of port P1 is read again, then P1.6 is set to 1, but P1.7 might still be too low to be considered a 1 and so a 0 is written to port P1.7 latch. This problem is very pronounced in the PIC16F series and users are advised against setting the bits as you have in the CLEAR: function.
You would realize much more reliability if you change the whole port with one instruction, MOV P1,#0xFF and MOV P3, #0x13. Also the same with your ALLON: function. Use MOV P1, #0x00 and ANL P3, #0xEC.
To use a variable resistor for any kind of control you are going to need a device with ADC or else provide an external ADC.


List of 36 messages in thread
LED CHASER      Jai Nair      01/12/13 13:41      
   To avoid problems      Hal Albach      01/12/13 15:10      
      RMW uses latch      Maarten Brock      01/13/13 06:37      
      LED CHASER      Jai Nair      01/14/13 01:19      
         very possible        Erik Malund      01/14/13 07:27      
            LED CHASER      Jai Nair      01/14/13 08:59      
               Do you know what comments are?        Richard Erlacher      01/14/13 11:20      
                  oddly enough      Erik Malund      01/14/13 11:33      
                     Very true      Kalpak Dabir      01/14/13 20:07      
                     Design your project in the first place        David Prentice      01/15/13 09:14      
               yes, when      Erik Malund      01/14/13 11:30      
                  led chaser_comment      Jai Nair      01/16/13 09:13      
                     it would be helpful      Erik Malund      01/16/13 09:42      
                        chip       Jai Nair      01/16/13 10:11      
                           read the datasheet      Erik Malund      01/16/13 11:51      
                              potentiometer      Jai Nair      01/16/13 23:27      
                                 Erik's typing      Andy Neil      01/17/13 02:13      
                                 RE: potentiometer      Andy Neil      01/17/13 02:28      
                              Not entirely true      Andy Neil      01/17/13 02:17      
                                 The AT89C2051 has analog comparator      David Prentice      01/17/13 02:32      
                                    LED currents      Jai Nair      01/17/13 11:56      
                                       no, you have not      Erik Malund      01/17/13 13:01      
                                          comment      Jai Nair      01/17/13 13:33      
                                             which is also uncommented scribbles      Erik Malund      01/17/13 13:46      
                                                comment      Jai Nair      01/18/13 09:42      
                                                   He wants you to put descriptive, detailed comments      Andy Neil      01/18/13 09:58      
                                                      thanks       Jai Nair      01/18/13 10:01      
                                                         Will you do it?      Andy Neil      01/18/13 13:02      
                                                            comment      Jai Nair      01/18/13 13:12      
                                                               A method I have used for LED signs        Erik Malund      01/18/13 13:46      
                                                                  OMG      Michael Karas      01/18/13 18:47      
                                                                     one example, please      Erik Malund      01/18/13 20:25      
                                                               bear in mind that not everyone will recognize "LED Chaser"      Richard Erlacher      01/22/13 09:27      
                                                   apparently you still don't know what comments are      Richard Erlacher      01/22/13 09:17      
   no, you don't      Erik Malund      01/12/13 19:41      
   ADC with 89C2051 comparator      Hal Albach      01/25/13 18:25      

Back to Subject List