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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/12/13 22:10
Read: times


 
#189142 - To avoid problems
Responding to: ???'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.

Hal

List of 36 messages in thread
TopicAuthorDate
LED CHASER            01/01/70 00:00      
   To avoid problems            01/01/70 00:00      
      RMW uses latch            01/01/70 00:00      
      LED CHASER            01/01/70 00:00      
         very possible            01/01/70 00:00      
            LED CHASER            01/01/70 00:00      
               Do you know what comments are?            01/01/70 00:00      
                  oddly enough            01/01/70 00:00      
                     Very true            01/01/70 00:00      
                     Design your project in the first place            01/01/70 00:00      
               yes, when            01/01/70 00:00      
                  led chaser_comment            01/01/70 00:00      
                     it would be helpful            01/01/70 00:00      
                        chip             01/01/70 00:00      
                           read the datasheet            01/01/70 00:00      
                              potentiometer            01/01/70 00:00      
                                 Erik's typing            01/01/70 00:00      
                                 RE: potentiometer            01/01/70 00:00      
                              Not entirely true            01/01/70 00:00      
                                 The AT89C2051 has analog comparator            01/01/70 00:00      
                                    LED currents            01/01/70 00:00      
                                       no, you have not            01/01/70 00:00      
                                          comment            01/01/70 00:00      
                                             which is also uncommented scribbles            01/01/70 00:00      
                                                comment            01/01/70 00:00      
                                                   He wants you to put descriptive, detailed comments            01/01/70 00:00      
                                                      thanks             01/01/70 00:00      
                                                         Will you do it?            01/01/70 00:00      
                                                            comment            01/01/70 00:00      
                                                               A method I have used for LED signs            01/01/70 00:00      
                                                                  OMG            01/01/70 00:00      
                                                                     one example, please            01/01/70 00:00      
                                                               bear in mind that not everyone will recognize "LED Chaser"            01/01/70 00:00      
                                                   apparently you still don't know what comments are            01/01/70 00:00      
   no, you don't            01/01/70 00:00      
   ADC with 89C2051 comparator            01/01/70 00:00      

Back to Subject List