【发布时间】:2018-03-10 11:29:33
【问题描述】:
我想添加一个 Timer1 ISR 以每 0.25 秒触发一次,并使用 WS2812 240 带状 LED 做一些轻微的运动。
在 Arduino Nano 上运行良好,因为它有一个
cli();
TCCR1A = 0; // pas de PWM ou OCR
TCCR1B = (0<<WGM13) | (1<<WGM12) | 4; // Clear Timer on Compare match (CTC) mode, OCR1A= PRD
// CS12 CS11 CS10 = 0b100 = 4 =>256 prescaler
OCR1A = 15625; // 62.5 ns * 15625 * 256 prescaler = 0.250 s
// pas de compteur logiciel
TIMSK1 = 1<<OCIE1A; // ISR on Output Compare1 (TCNT1==OCR1)
TIFR1 = 0; // clear T1 IF
TCNT1 = 0; // RAZ T1
sei();
现在我搬到 ESP8266,在我的项目中也使用 Wifi,没有 OCR,所以我尝试使用 Timer1 ISR(Timer0 用于 Wifi)。
单独使用:
//setup
timer1_attachInterrupt(myTimer1_ISR);
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);
timer1_write(300000); //120000 us/2
...
void ICACHE_RAM_ATTR myTimer1_ISR()
{
//.....
timer1_write(300000);//12us/2
}
但是对于 NeoPixels 库,它会给我带来冲突:
错误:void myTimer1_ISR() 导致节类型与静态冲突 volatile void NeoEsp8266DmaMethodBase::i2s_slc_isr() [with T_SPEED = NeoEsp8266DmaSpeed400Kbps]
void ICACHE_RAM_ATTR myTimer1_ISR(){
在包含的文件中 ...Arduino\库\NeoPixelBus_by_Makuna\src/NeoPixelBus.h:67:0,
我相信,NeoPixel 代码也使用 Timer1? 我该如何管理? 谢谢
【问题讨论】: