[Icc-mot] function prototype for specific address

Edward Karpicz ekarpicz at freemail.lt
Mon Jul 23 12:47:25 PDT 2007


Wade A Smith wrote:

> I'm trying to find out how to set up an address as the target for a call
> from C.
>
> Example,
>
> typedef void (*SFn)(void);
>
> #define SPECIAL_FN      0xF654
>
> unsigned char EEPgmBuf[64];
>
> main()
> {
>    ....
>    (SFN)  SPECIAL_FN();                // one useage
>


compare above line ^^ to this

    (char) rand();


Both lines are "call the function, then type cast". But SPECIAL_FN isn't a 
function. Add round brackets to make type-cast preceding the call():

((SFN)SPECIAL_FN)();



>
>    // load function into RAM
>    // then setup for EEPROM erase/write
>    EEdest = &EEData;
>    EEsrc=&ramData;
>    (SFN)  &EEPgmBuf();                // another useage

((SFN) EEPgmBuf)();


>
> Anyone know how to do this? other than using asm("") all over the place?
>
> While I'm at it, anyone able to erase/write S12D64 EEPROM while still
> handling interrupts (communication still working)?
>

Do you mean *flash* EEPROM programming? Yes, interrupts should be disabled 
for flash program/erase time. That's because flash is not readable while 
programming/erasing; and since it's not readable -  if interrupt would occur 
while programming, then CPU couldn't fetch valid vector from flash and 
execute valid interrupt service code.
Word program time is <75us. You could disable interrupts for word program 
time and still have quite high rate SCI interrupts working. But setor erase 
time is indeed really long. If really necessary then RAM could be remapped 
to vector area, vectors and ISR's should be moved to RAM. Do you really need 
interrupts always enabled?

Edward



> wade
>
> _______________________________________________
> Icc-mot mailing list
> Icc-mot at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-mot
> 




More information about the Icc-mot mailing list