Surprisingly Useless PIC18F Discovery

Thread Starter

joeyd999

Joined Jun 6, 2011
5,220
Having used the 18F series Microchips for many years, I thought I knew everything about them...

Perusing the 18F85J90 family datasheet last night, I saw something I'd never noticed before: The CALL and RETURN instructions have an extra argument 's'.

According to the datasheet, if the 's' argument is 1, then WREG, STATUS, and BSR are pushed onto the "fast return stack" for a CALL and popped off the stack for a RETURN.

Neat, I thought...I could find some use for this.

But, playing around, I realized that the "fast return stack" in question is the same fast return stack that is used for interrupts, regardless if RETFIE FAST instruction is used or not.

So, basically, the stack gets corrupted if an interrupt is triggered in the middle of a subroutine that uses it. I suppose one could disable interrupts prior to making the call and re-enabling them after the return. But that doesn't make much sense.

So, this CALL/RETURN option seems to be useless -- and dangerous for the uninitiated -- yet no cautionary statement is made in the entire datasheet. It's a wonder they included it in the instruction set.

Just thought I'd bring this up for those who might be interested.
 
Top