想用CY8C24533 的定时器中断中进行四位数码管的扫描,数码管电路没有为题,但不知道定时器哪里设置不对,还是程序有问题,不能进入定时器中断。请高手指教下,感谢!
代码如下:
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
unsigned char LED_COUNT=0;
// 0, 1, 2 3 4 5 6 7 8 9 P A D C T b u - H L n h _ u o e E
const Led_Table[]={0xC0,0xF9,0XA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x8C,0x88,0xA1,0xC6,0x87,0x83,0xC1,0xBF,0x89,0xC7,0xC8,0x8B,0xF7,0xE3,0xA3,0x84,0x86,0xA7};
void Delay(unsigned int i)
{
while (i--);
}
void LED_SHOW()
{
PRT1DR=0xFF;
PRT0DR=0x00;
if (LED_COUNT==0)
{
PRT0DR=0x01;
}
if(LED_COUNT==1)
{
PRT0DR=0x04;
}
if (LED_COUNT==2)
{
PRT0DR=0x10;
}
if (LED_COUNT==3)
{
PRT0DR=0x40;
}
PRT1DR=Led_Table[LED_COUNT];
LED_COUNT++;
if (LED_COUNT==4) LED_COUNT=0;
}
#pragma interrupt_handler Timer8_1_ISR
void Timer8_1_ISR(void)
{
LED_SHOW();
}
void main(void)
{
// M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
// Insert your main routine code here.
M8C_EnableGInt;
PRT1DR=0xC0;
//Timer8_1_WritePeriod(31);
Timer8_1_EnableInt();//启用中断模式运行。但是,要注意到,在中断运行前,必须还启用全局中断。
while (1)
{
//LED_SHOW();
Delay(500);
}
}
另上传源程序压缩包 |