gpt4 book ai didi

c - 错误 : attempt to use poisoned "SIG_OUTPUT_COMPARE0A"

转载 作者:太空宇宙 更新时间:2023-11-04 01:09:51 25 4
gpt4 key购买 nike

我正在为 atmega168a 编写 C 代码。当我编译下面的代码时,出现了 attempt to use poisoned "SIG_OUTPUT_COMPARE0Aattempt to use poisoned "SIG_OUTPUT_COMPARE0B 错误。但我在 http://www.protostack.com/blog/2010/09/timer-interrupts-on-an-atmega168/ 上看到 ISR 函数的类似用法如果有人能告诉我我做错了什么,我将不胜感激?我正在使用 atmel studio 6.0 及其 gcc 在 Windows 7 电脑上编译代码。

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/iomx8.h>


volatile int new_msg;
volatile int new_msg_available = 0;
volatile int message = 0xFFFF;
int main(void)
{
DDRB = 0xFF;
TIMSK0 = _BV(OCIE0A) | _BV(OCIE0B); // Enable Interrupt TimerCounter0 Compare Match A & B // #define OCIE0A 1... (1<<1);
TCCR0A = _BV(WGM01); // Mode = CTC ... #define WGM01 1 ... mode 2
TCCR0B = _BV(CS01); // Clock/8, 0.000008 seconds per tick
OCR0A = 104; // 0.000008*104 = 0.000832 SIG_OUTPUT_COMPARE0A will be triggered.
OCR0B = 52; // 416 usec

message = 0xFFFE;

volatile int i;
sei(); //interrupts are globally switched on


while(1)
{
if (OCR0A >= 104){
for (i=0; i<18; i++) {
if (i <2){
PORTB = 0xFF;
}
else if ((i<15) && (message & 0x1)) {
PORTB = 0x00;
}
else if (i>15){
PORTB = 0xFF;
}
else{
PORTB = 0x00;
}
message >>= 1;
}
}
}
return 0;
}


ISR(SIG_OUTPUT_COMPARE0A)
{
if(new_msg_available == 1){
message = new_msg;
new_msg_available = 0;
}else{
message = 0xFFFF;
}
}

ISR(SIG_OUTPUT_COMPARE0B)
{
PORTB ^= 0xFF;
}

最佳答案

您使用的是过时的中断名称。

参见:avr-libc documentation, "Interrupt vector names"

要使用的新名称是 ISR( TIMER0_COMPA_vect )

关于c - 错误 : attempt to use poisoned "SIG_OUTPUT_COMPARE0A",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15174021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com