Quote Originally Posted by languer
What chip are you using?

>Its the 16F690

The interrupt control register should already be mapped in the INC file for that chip. This would be the name you use (instead of CONTROL) -> most likely INTCON.

Yes, I am dealing with INTCON too, in the usual way. The lines of code I wrote in the example just refer to the relevant parts of my program.
I use 'Control' to indicate certain functions have created an interupt. For example, if the Usart receives a byte of data I set Control,1. if the interupt is caused by a succesion of timer 1 overflows, enough to create a 1second time period I set bit Control,0.

I am doing it this way because i need the interupt accuracy for timing purposes, IE without the latency created when dealing with interupts through PBP.

Later, when the interupt is over, and at a time convenient to me (in programming terms) I check the bits of CONTROL and act accordingly
. In this way the data never overflows and the timing period is accurate regardles of what pbp instruction is being executed. Perhaps if executing a long pause statement 5 data bytes could be received, this would cause an overflow error.


As it is CONTROL is a variable and when you do bsf _CONTROL,1 you're trying to set the flag on the register located at CONTROL (whatever that value happens to be at the time).

> Erm, I'm not quite sure that's entirely true. The command actually sets bit number 1 in the address pointed to by the label CONTROL. That's what Microchip datasheets have always said anyway....




So depending on how that variable is defined (or initialized) you may be setting a flag in the INTCON register or some where else. When you read CONTROL.1 you're just reading the variable, not the register (see you never change the variable in assembly - you try to set the flag in the register pointed to by CONTROL).

> ah okay, i see what details you're saying I've got confused about, but it's not the case. CONTROL is declared as a user variable, and presumably pbp is assigning it to an address at or above $20. The INTCON register is at a lower address, and it has to be fair to assume that pbp absolutely does perform this action, otherwise it would never work.

I am going to be using FSR and INDF at a later point but it's commented out at the moment so that's not a cause of confusion at the moment.


Just look at the INC file, but it would probably be something like this:

Code:
asm
bsf INTCON,1
endasm
...
IF INTCON.1 =1 THEN
;do action
ENDIF

Do you mean the LST file instead ? The INC file contains the address of the SFR's and the numbers and names of the bits in those registers, as well as the config data setups, and badram data area info.

I suppose in simple form my question is this............
WHen the manual says that if I declare a variable with VAR BYTE in basic and I can access that variable with an underscore in front of it's name in assembler how come nothing changes when I bsf a bit in assembler and try reading it back it's state later on ?