I have read the datasheet several times but I am finding it hard to adapt it to the aplication I am making with the language I am using(basic).
If someone said to me "bit 5 of the cheese register is high when its a timer interrupt, it is low if it is a pin interrupt" i can handle that.
I just find that when I look through the datasheet its all in Double Dutch or something!
I'll have another look through the data sheet and post back here when I think I know what im doing.
btfsc PIR1,TMR2IF ; If Timer 2 caused the interrupt, handle it.
call Timer2
This is a section of code out of an interrupt routine, it checks to see if timer2 has caused the interrupt, calling the processing routine if it did, if not it simply carries on. The rest of the interrupt routine obviously saves and restores the various registers.
Sorry to keep being a pain Nigel, but my assembly isnt great.
I know btfsc means Bit test, skip if clear.
I assume the first value is the register to test.
What does the other do? Is it the name of the bit in the register?
Have you assigned this to a number for ease of use? or is the bit actually called TMR2IF ? What number bit is this in the register?
I am checking if the bit is clear, so do I just check which register is clear to work out which code to execute?
In my language I just use
Code:
if PIR1.TMR2IF = 0 then
This tests if the TMR2IF'th bit of the PIR1 register is clear? Is that right?
Sorry to keep being a pain Nigel, but my assembly isnt great.
I know btfsc means Bit test, skip if clear.
I assume the first value is the register to test.
What does the other do? Is it the name of the bit in the register?
Have you assigned this to a number for ease of use? or is the bit actually called TMR2IF ? What number bit is this in the register?
All the names are in the include file for the specific PIC, that's what the include file is for. You can check the include file to find what bit it is, or consult the datasheet - you really should consult the datasheet, all the answers are in there.
I am checking if the bit is clear, so do I just check which register is clear to work out which code to execute?
In my language I just use
Code:
if PIR1.TMR2IF = 0 then
This tests if the TMR2IF'th bit of the PIR1 register is clear? Is that right?
I can't comment on your specific language, particularly inside interrupt routines, but that's the right sort of idea.
But again - READ THE DATASHEET - everything is explained there, also learn a reasonable amount of assembler - you can't use a high level language effectively without understanding assembler!.