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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/12/00 23:09
Read: times


 
#2657 - RE: 8031 question
You only need interrupts when a fast (and I mean f-a-s-t like microseconds) response is required to capture an action or an event that would be missed otherwise, or which would cause problems if not immediately attended to. Interrupts are to be avoided by beginners. Leave them off – the default state at power up.

Write ones to the port pins that you want to monitor (to configure them as inputs). Connect the individual switches to individual input pins. If you wire the switch between the pin and ground then a pull-up resistor from the pin to Vcc is generally called for. The value is not in any way critical – anything from 1K to 100K to each input pin. You read the state of the switches by reading from the micros port registers. If you read the whole byte then you will need to mask off unused bits (inputs) with an And Immediate instruction so that the unused bits are not tested too. The 8031 has Boolean instructions which will test individual bits though.

Create a short program that polls the required input pins to check the state of the switches, and then loops back to the start with a jump instruction; this is called a polling loop. You can then program any simple algorithm you want. Any actions you take in this loop will appear almost instantaneous as even with a large loop the pins will be checked (and the testing acted on) thousands of times a second.

Remember to drive the LEDs through current limiting resistors or you will damage the micro or the LEDs or both. Let me know if you don’t see how to calculate the correct resistor values for the displays.

List of 4 messages in thread
TopicAuthorDate
8031 question            01/01/70 00:00      
RE: 8031 question            01/01/70 00:00      
RE: 8031 question            01/01/70 00:00      
RE: 8031 question            01/01/70 00:00      

Back to Subject List