|
|
View previous topic :: View next topic |
Author |
Message |
Bangheadondesk
Joined: 26 Apr 2005 Posts: 7
|
How to get round fast interrupt silicon errata problem |
Posted: Thu Feb 09, 2006 9:12 am |
|
|
Hello,
I am trying to get around a problem with the PIC18F4620 in which a fast interrupt occuring in the middle of certian two byte instructions causes the fast return stack wreg value to be incorrect. According to the Microchip erata sheet the problem can be avoided by performing a dummy fast call to store the actual state of the STATUS, BSR and WREG registers in the fast return stack. The dummy functions return address can then be removed by popping it of the stack before running the real ISR code and performing the fast retfie to restore the original processor context i.e.
ISR @ 0x0008
CALL Foo, FAST ; store current value of WREG, BSR, STATUS for a second time
Foo:
POP ; clears return address of Foo call
: ; insert high priority ISR code here
:
RETFIE FAST
My issue is that I don't know how to call a C function from inline assembly and so I am doing it as shown below. For some reason the compiler (3.233) wont except a fast call instruction, has anybody got any ideas on how to do this?
#int_ext1 FAST noclear
void fast_isr( void )
{
//silicon errata workaround
//fast call tach isr to re-save processor BSR, WREG and STATUS registers
#asm ASIS
call 0x400 1 //this instruction will not compile!!!!!
#endasm
}
#org 0x400, 0x450
void tach_isr( void )
{ //Tachometer input ISR
//CCS appears to provide the FAST return opcode (WREG, STATUS stored in fast return stack)
int8 scratch0;
#asm
//pop last return address
pop
//store current state of processor
movff 0x03, scratch0
#endasm
//..................................External interrupt 1 (TACHOMETER input) ISR
if( INT1IF )
{ //check for tachometer interrupt
ext1_handle();
INT1IF = 0;
}
#asm
// restore processor and return from interrupt
movff scratch0, 0x03
retfie 0x01
#endasm
}
Many thanks |
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 09, 2006 11:21 am |
|
|
The easiest way, is probably just to ask CCS for an erratum fix.
The problem is that CCS, does not contain an assembler as such, but an 'assembler subset', with a peculiar combination of assembler and C syntax, which is also largely undocumented. This feeds it's output to the assembler underneath, but you have no access to this (except tolook at the .lst files). Unfortunately, the instructions that exist in the latter, are not always present in the former.
In the past it took ages for them to add support for retfie 1. As a work around, I coded a normal retfie, looked at the assembler listing, and then added a #rom statement, to put the required value into place.The same fix would work for your problem.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|