stm8l152 tim4中断
我在做STM8L TIM4中断程序时编译程序在 stm8_interrupt_vector.c中在typedef void @far (*interrupt_handler_t)(void);处产生
Error: expected a declaration D:\STM8\各种练习性代码\STM8L_TIME\stm8_interrupt_vector.c 8
Error: identifier "interrupt_handler_t" is undefined D:\STM8\各种练习性代码\STM8L_TIME\stm8_interrupt_vector.c 12
象是interrupt_handler_t无定义。
求教解决的办法。
回复:stm8l152 tim4中断
原来stm8_interrupt_vector.c 是STVD中的程序,加入到IAR中就报警了。我的TIM4程序如下:
void TIM4_INIT(void)
{ /* Init TIMER 4 */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4,ENABLE);
/* Time base configuration */
TIM4_TimeBaseInit(TIM4_Prescaler_8192,122); //设置分频、时间
/* Clear TIM4 update flag */
TIM4_ClearFlag(TIM4_FLAG_Update);
/* Enable update interrupt */
TIM4_ITConfig(TIM4_IT_Update,ENABLE); //开启溢出中断
enableInterrupts();
/* Enable TIM4 */
TIM4_Cmd(ENABLE); //启动定时器
}
主函数如下:
void main(void)
{ uint8_t a,b,c,d;
CLK_INIT();
StartHSE();
IO_INIT();
LCD_OPEN();
LED_init();
KEY1_init();
KEY23_init();
TIM4_INIT();
enableInterrupts();
Delay(1000);
while(1)
{ 。。。。。。
中短函数stm8l15x_it.c 中TIM4部分如下
/**
* @brief TIM4 Update/Overflow/Trigger Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM4_UPD_OVF_TRG_IRQHandler,25)
{
TimingDelay_Decrement();
TIM4_ClearITPendingBit(TIM4_IT_Update);
}
程序无法进入中断
RE:stm8l152 tim4中断
STVD和IAR有一些写法是不一样的。如果是从STVD移植到IAR上的话,注意一下工程中是否定义了_COSMIC_。
RE:stm8l152 tim4中断
我在调试中执行CLK_PeripheralClockConfig(CLK_Peripheral_TIM4,ENABLE);
后CLK_PCKENR1=0x04
说明TIM4时钟已开启,执行完TIM4_INIT();后
TIM4_CNTR一直为0,不向上加,所以一直没有中断发生。
应该是每走一步TIM4_CNTR加1的,从现象上看TIM4时钟没打开,
怎样打开TIM4时钟?
回复:stm8l152 tim4中断
我看是这样配置的。RE:stm8l152 tim4中断
我找到原因了,在main中定义的变量uint16_t TimingDelay;在stm8l15x_it.c中没声明引用,所以TimingDelay变量始终是0,将extern uint16_t TimingDelay;加到main,h后程序能正常运行了。RE:stm8l152 tim4中断
void main(void){ uint8_t a,b,c,d;
CLK_INIT();
StartHSE();
IO_INIT();
LCD_OPEN();
LED_init();
KEY1_init();
KEY23_init();
TIM1_INIT(); //在此处改变定时器,TIM1~TIM4都能运行
enableInterrupts();
Delay(1000);
PCB板为美女板
RE:stm8l152 tim4中断
附件没有传出去呀。RE:stm8l152 tim4中断
美女板程序搞定,遗憾的是TXD引脚内部坏了只能输出不能输入,PB3引脚断了所以W25X16没用上。
页:
[1]