CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to get round fast interrupt silicon errata problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Bangheadondesk



Joined: 26 Apr 2005
Posts: 7

View user's profile Send private message

How to get round fast interrupt silicon errata problem
PostPosted: Thu Feb 09, 2006 9:12 am     Reply with quote

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







PostPosted: Thu Feb 09, 2006 11:21 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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