Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

4 bit LCD Code needed

Status
Not open for further replies.
I would be writing the code from scratch so I would factor other uses into the program. I often use timers for more than one purpose though, all you do is trigger an ISR at the shortest time interval the program needs and use software counters to create longer delays from it. For example:

Code:
InteruptRoutine
clrf INTCON,TMR0IF  ; clear the interrupt flag
movlw 0x55  ; reload the timer interval
movwf TMR0
bsf  TimerFlags,0 ; indicate the short interval has finished
decfsz Counter,f  ; count down for the longer interval
retfie
bsf TimerFlags,1  ; indicate the longer interval has finished
retfie

This sets bit 0 of a variable called TimerFlags each time the interrupt occurs and if the value you put in 'Counter' has also reached zero it sets bit 1. The code is over-simplified and in reality you would monitor and reset the bits in the main loop of the program. The idea is that if you loaded 'Counter' with say 25 and TMR0 rolled over every 10mS, bit 0 in TimerFlags would set every 10mS and bit 1 would set every 250mS so you have generated two intervals from one timer. The beauty of this method is you can set up many different 'Counter' variables and load them with different values in the program as needed, you can even change them while the program is running.

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top