Can a pic do several things at once?
NO, even your PC on your desk can not.
That is where interrupts come in.
In you case an interrupt on the serial input should do the trick.
What happens with an interrupt, when an event takes place that is tied to the interrupt routine (internal or external) a "flag" is set. When the PIC or your PC gets time (finishes whatever it is doing ) it will then do the routine called by the interrupt. Then go back to normal operations until the next "flag" is set.
One PIC will work. If speed is a factor , Darrel's Instant Interrupts will be what you want.
First I would play with interrupts with an pin going high to be the trigger to get the feel of things.
A little of what the coding looks like for the above example.
Code:
ON INTERRUPT GOTO MYINT
INTCON = %10010000
'###################
'MAIN PART OF PROGRAM
'###################
DISABLE
MYINT:
IF PORTB.0 = 1 THEN
PC = PC + 1
WRITE 3,PC.BYTE0
WRITE 4,PC.BYTE1
READ 3,PCNT.BYTE0
READ 4,PCNT.BYTE1
pause 100
ELSE
PC = PC
ENDIF
INTCON.1 = 0
RESUME
ENABLE
'THE ABOVE WILL ALSO DEBOUNCE THE SWITCH
This is a snippet from one of my programs just so you can see what to do. It has nothing to do with your app. But it does show how to write to the EEPROM.
Bookmarks