c - PSoC 定时器中断

标签 c embedded interrupt psoc

在我看来,我的定时器中断不能正常工作。问题是中断函数中的计数器只增加一次。这是我的主要和计时器设置代码。

#include <m8c.h>
#include "PSoCAPI.h"
#include <stdio.h>
#include <stdlib.h>

char theStr[] = "PSoC LCD";
static char tmp[3];
static int counter = 0;

void main(void){

    LCD_Start();
    LCD_Position(0,5);
    LCD_PrString(theStr);
    M8C_EnableGInt;
    Timer8_EnableInt();
    Timer8_Start();
    while (1);
}

#pragma interrupt_handler myTimerInt
void myTimerInt(void){
    counter ++;
    LCD_Position(1,0);
    itoa(tmp, counter, 10);
    LCD_PrString(tmp);
}

最佳答案

大多数中断服务例程需要重新准备调用它的中断(有时称为“确认中断”)。否则,ISR 只会被调用一次。通常,这是在 ISR 的关键部分完成后完成的。

对于 503418,我认为重新启用是通过读取计数寄存器来完成的。查看this底部的代码.

关于c - PSoC 定时器中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22743142/

相关文章:

c - 仅使用递归如何实现 O(log n) 幂函数 a^n ?

c - 指向结构体指针和数组的 malloc 内存

c - PIC32与RTC集成

exception - 中断和异常

c - C 中的宏与预定义数据类型在存储方面有何不同?

gcc - 使用链接器映射内存

转换可变位大小的有符号整数

c - 这两个中断服务程序中的竞争条件是什么?

linux-kernel - 我的中断处理程序应该禁用中断还是 ARM 处理器自动执行此操作?

Linux中的C程序: Output Redirection Performance