|
|

|
|
| Listing 4
Use a lookup function to detect an interrupt and retry RETLW.
|
uint8 _TableLookup_( uint8 const *addr )
{
//// _FUNCTION 0,_TableLookup_,0,0
//// fmovwf Gen+0 ;addr lo
// Return the value in the table.
////; Preserves FSR, Gen+1 to Gen+3. Gen+0 is set to WREG.
register
uint8 result;
do
////LMN431: crpor BIT_RADDR(InterruptOccurred)
result = _Retlw_( (uint16) addr );
//// ;;fmovfw Gen+0 ;addr lo - W is ignored by _Retlw_
//// fcall __Retlw_
//// ; Dont assume PCLATH<3>s setting...
////Cpage SET CP_BOTH
while (InterruptOccurred);
//// fbbs BIT(InterruptOccurred),Cpage,LMN431
return result;
//// freturn __TableLookup_
}
uint8 _Retlw_( uint16 addr )
{
//// _FUNCTION 0,_Retlw_,0,0
// Only called by _TableLookup_.
////; Preserves
FSR, Gen+0 to Gen+3.
////; NOTE!!!: Gen+0 is assumed to be addr lo
//// ;;fmovwf Gen+0 ;;this is done in _TableLookup_
PCLATH = (uint16) addr >> 8;
//// fmovff Gen+1,PCLATH
WREG = (uint8) addr;
//// fmovfw Gen+0
InterruptOccurred = FALSE;
//// fbcf BIT(InterruptOccurred)
PCL = addr;
//// movwf PCL ;jump to a retlw xx command
return 0; // avoid a compiler error
}
|
Back
|
|
|
|
|