You have to tell the compiler that "MyTimer16Interrupt" is an interrupt handler by declaring
#pragma interrupt_handler MyTimer16Interrupt
See "ImageCraft C Compiler Guide"
Thanks Bob, I did do this (add the #pragma statement) but am still having problems.
To try and get it working, I have created a simple project that does nothing more than setup a timer16 and interrupt on terminal count. During the ISR, it is supposed to toggle a port line.
The project is for CY8C29466-24PXI. There is one User Module placed - a Timer16 - placed in blocks DBB00 and DBB01. It is clocked from VC1 which is set to SysClk/1 so it should be running at 24 MHz.
Port0_2 pin has been set as 'strong' drive mode in the Designer.
The code reads:
M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
// Insert your main routine code here.
//setup and start Timer16
#pragma interrupt_timer Timer16Interrupt
unsigned static int State;
if (State == 0)
PRT0DR |= 0x04; //set Port0_2 pin high
State = 1;
PRT0DR &= ~0x04; //clear Port0_2 pin low
State = 0;
Also, I have modified the boot.tpl file so that the relevant portion reads:
org 20h ;PSoC Block DBB00 Interrupt Vector
org 24h ;PSoC Block DBB01 Interrupt Vector
The reason I have put this in twice is because I couldn't find any definitive statement telling me from which block the interrupt should be associated with for a Timer16 User Module terminal count. The Design view image suggests that it would be the second block, but as this didn't work, I gave it both blocks.
Still there is no activity on the pin. I only have a MiniProg so can't debug.
Any ideas of what to try next? I couldn't find an example project that uses Timer terminal count as interrupt. Mine is attached in non-working condition.
Timer16Test29466.zip 197.1 K
You need a Build -> Generate/Build Current Project. The information from the .tpl file weren't transferred into the boot.asm file.
What do you think about changing to PSoC4? Prototyping Kits start at $10.
Thanks again, Bob, I have got it working now.
The Generate/Build gave me a warning: !W C:\Users\Tony902\DOCUME~1\PSOCDE~1.4PR\TIMER1~1\TIMER1~1\TIMER1~1\main.c(24):[warning] unknown #pragma interrupt_timer
#pragmashould of course have been
#pragma interrupt_handler, not
#pragma interrupt_timer. I must have typed that absent-mindedly, thinking about the function I wanted to achieve.
And I have confirmed that the interrupt is associated with the second block in the Timer16 User Module.
The PSoC4 does look interesting, I may give this a try in the near future. I like the fact that it incorporates a debugger into the low-cost dev kit - very handy. I am using a lot of digital blocks in the PSoC1 in this project - is there anything that the PSoC4 can't do compared with the PSoC1?
PSoC4 hasn't got that kind of analog blocks the PSoC1 has. So no analog filters except using the OpAmps.
You can download and install Creator 4.0 and the kit installation files to see what you will get.