Complete newbie question (TMS470)

Hey guys, first post, wondering if you could help me out?

Currently trying to develop applications for a TMS470R1A256 ARM processor using the IAR Kickstart compiler provided by TI.

Does anyone have any idea how to make an interrupt (a timer interrupt in this case) call a function when it occurs?

I’m used to assigning vectors and branching, in a startup file, to the function required. This processor (or compiler) doesn’t seem to function like that.

Like the title suggests, I am a newbie, only just started out, so go easy please if this is a stupid question or I don’t sound like I know what I’m talking about.

Jon

It should be in the IAR documentation. It’s quite easy with the CrossWorks tools I use for the LPC ARM chips.

Leon

jonloveslou:
Hey guys, first post, wondering if you could help me out?

Currently trying to develop applications for a TMS470R1A256 ARM processor using the IAR Kickstart compiler provided by TI.

Does anyone have any idea how to make an interrupt (a timer interrupt in this case) call a function when it occurs?

I’m used to assigning vectors and branching, in a startup file, to the function required. This processor (or compiler) doesn’t seem to function like that.

Like the title suggests, I am a newbie, only just started out, so go easy please if this is a stupid question or I don’t sound like I know what I’m talking about.

Jon

In my case, I do something like this in ARM assembler in the startup code to call a C procedure from an interrupt. AFAIK, there should be no compiler dependencies doing it this way as long as the linker can provide the address of the C procedure? However, this assembler syntax is specific to the ARM assembler. This handler is jumped to from the IRQ vector in the vector table starting at address zero.

;***********************************************************

IMPORT C_PROC ; Name of C procedure to call

IRQ_Handler ; Handler Label

SUB LR, LR, #4 ; Adjust for correct return

STMFD SP!,{R0-R3,LR} ; Save some registers

BL C_PROC ; Call the C procedure

LDMFD SP!,{R0-R3,PC}^ ;Pop and Return from Int.

;************************************************************

–Dave

Hi Jon.

I don’t have my files available, but I am 99% sure there is an example of what you describe somewhere on the CDs that come with the IAR kits. If you can’t find it, let me know and Ill go digging.

dshuman:
In my case, I do something like this in ARM assembler in the startup code to call a C procedure from an interrupt.

Yeah, this is how I’ve done it before, when programming the LPC2000 family. But with programming this chip, I can’t find any startup code! At least, no files that contain assembly code anyway.

tarun:
I don’t have my files available, but I am 99% sure there is an example of what you describe somewhere on the CDs that come with the IAR kits. If you can’t find it, let me know and Ill go digging.

There are some tutorial codes that come with the package and one of them uses interrupts as a means to call functions but it is for a different processor! I don’t have the actual CD though, I downloaded the IAR Kickstart IDE so if you can find the files, I’ll definitely take a look!

Many thanks guys.

Jon

jonloveslou:

dshuman:
In my case, I do something like this in ARM assembler in the startup code to call a C procedure from an interrupt.

Yeah, this is how I’ve done it before, when programming the LPC2000 family. But with programming this chip, I can’t find any startup code! At least, no files that contain assembly code anyway.

You should be able to find “tms470_cstartup.s79” in your IAR installation according to the documentation on TI’s website. I looked at the example that I found, and it is an assembly language startup file. Apparently that is IAR’s default startup file, so you should be able to copy it and modify it for your own needs. I use SDT2.51 and not IAR, so I can not tell you the path to that file, but the documentation at the TI site say that it is in the IAR installation from what I can see. Since the processor in the TMS470R1A256 is an ARM7TDMI you should be able to start just as you did with the ARM7TDMI in the LPCxxxx series???

–Dave

Thanks for your help guys!

Unfortunately, I couldn’t figure what on Earth was going on with startup files. They weren’t in my project folder and there were many, many copies in the IAR installation folder.

However, in an example project provided by the IAR Kickstart program, the following functions were used instead:

#pragma vector=0x18
__irq __arm void irq_handler()
{
  volatile int vecno;

  vecno = CIMIVEC;     // read and clear interrupt
  (*timer_function)(); // Call timer callback function.
}


//
// Interrupt functions.
//

void TMS470InitInterrupt(void(*timer_func)())
{
  timer_function = timer_func;

  // Setup interrupt controller.
  REQMASK |= (1<<2);    // Enable channel 2  (RTICMP1)
}

All that was required was to call the bottom function in your main code, passing through the name of the function you want to execute when an interrupt occurs (in this case a compare counter interrupt).

Now I just need to figure out why it isn’t running at the speed it should be…