When creating or using a C source startup application you usually have a file called 'intprg.c' that has all of your interrupt service routines defined. Also in this file the interrupt vector table is defined. This is done by using the '#pragma interrupt function_name(vect=##)' directive. Here the ## is the Software Interrupt Number of this interrupt which you can find in your part's Hardware Manual under the Interrupt section. The 'function_name' is the name of the function you want to service the interrupt you defined with the ##. So on an M16C/62P, if you wanted to define the function 'TimerA0_INT' to service the Timer A0 interrupt you would specify it this way: #pragma interrupt TimerA0_INT(vect=21) The vector number (21) was found in the Hardware Manual under the Relocatable Vector Tables subsection. If you have an assembly routine that you would like to service the interrupt you cannot use this same directive. The reason for this is that the #pragma interrupt directive only works when it is in the same file as the routine. This also means that if you put the directive in one file and the C code routine in another file, it will not build the vector table correctly. It will not give you an error, but it will not put that routine's address in the vector table. In order to use assembly routines with C source startup projects you just need to use the .rvector ##, function_name directive in your assembly source file. This is very similar to the directive mentioned earlier. The same example from above would look like this now: .rvector 21, TimerA0_INT An example project is attached.
There are no comments on this document