calling a c function from assembly ISR

hi Am using PSoC designer with complier IMAGECRAFT. I want to call a C function for CRC8_CCITT from an assembly ISR. I have to pass an argument and the funtion should return a value also.

Can somebody help me to do this.....

Thanks, serene

Reply to
serene
Loading thread data ...

I haven't used their PSoC compiler but based on the Imagecraft compilers that I do use, check the help file in the section "Programming the [ ]" for the "Inline Assembly" topic and in the section "C Runtime Architecture" for "Assembly Interface and Calling Conventions."

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

Failing that, nearly all C compilers will compile to assembly. If the manual doesn't help, or if you want to make sure, compile some code to assembly and see (a) how it calls functions and (b) how called functions get their parameters.

Generally a compiler will put have the processor put variables onto the stack or into registers to pass them as parameters, and it will put variables into registers (or into some special 'return value area' in memory if they're really register-starved) to return values.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

Are you absolutely sure that the routine is re-entrant ?

Does the C-compiler offer some extensions for writing ISRs in C ? If so, write your ISR in C and call that function from there, unless the manual restricts what can be called from the ISR.

If the C-compiler does not support ISR extensions, it is quite likely, that the library may have all kinds of re-entrancy problems.

If you do not have the sources for the function, link it to an ordinary program and disassemble it or step through it to check for any redundancy issues. You will also notice what calling convention is used.

Paul

Reply to
Paul Keinanen

Yes, it does. This is an example of interrupt written in C for Imagecraft:

#pragma interrupt_handler Timer_ISR void Timer_ISR(void) { PRT1DR &= 0xbf; sysclock++; PRT1DR |= 0x40; }

In addition the corresponding interrupt vector should contain the proper jump, like:

org 20h ;PSoC Block DBB00 Interrupt Vector // call void_handler ljmp _Timer_ISR

For PsoC Designer this is in boot.asm file

Reply to
Adrian

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.