diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp index 03ead2d2923f7c9096130a97ad52635063a11be8..d7356a4f3254b82e8920c08cda99d1cacb606bbd 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp @@ -191,14 +191,24 @@ void __attribute__((used)) cstirqhnd2(){ } interruptTransceiverTimerRoutine(); } + //CC1 for output/trigger the sending packet event if ((TIMER2->IEN & TIMER_IEN_CC1) && (TIMER2->IF & TIMER_IF_CC1) ){ - TIMER2->IEN &= ~ TIMER_IEN_CC1; TIMER2->IFC = TIMER_IFC_CC1; - - TIMER2->CC[1].CTRL = (TIMER2->CC[1].CTRL & ~_TIMER_CC_CTRL_CMOA_MASK) | TIMER_CC_CTRL_CMOA_CLEAR; - TIMER2->CC[1].CCV = static_cast<unsigned short>(TIMER2->CNT+10);//static_cast<unsigned int>(tick & 0xFFFF); - interruptTransceiverTimerRoutine(); + if(faseTransceiver==0){ + //get nextInterrupt + long long t=ms32chkp[0]|TIMER2->CC[1].CCV; + long long diff=t-IRQgetTick(); + if(diff<=0xFFFF){ + TIMER2->CC[1].CTRL = (TIMER2->CC[1].CTRL & ~_TIMER_CC_CTRL_CMOA_MASK) | TIMER_CC_CTRL_CMOA_SET; + faseTransceiver=1; + } + }else{ + TIMER2->IEN &= ~TIMER_IEN_CC1; + TIMER2->CC[1].CTRL = (TIMER2->CC[1].CTRL & ~_TIMER_CC_CTRL_CMOA_MASK) | TIMER_CC_CTRL_CMOA_CLEAR; + TIMER2->CC[1].CCV = static_cast<unsigned short>(TIMER2->CNT+10); + interruptTransceiverTimerRoutine(); + } } } @@ -413,8 +423,6 @@ void HighResolutionTimerBase::cleanBufferGPIO(){ } void HighResolutionTimerBase::setModeTransceiverTimer(){ - - //For input capture feature: //Connect TIMER2->CC0 to pin PA8 TIMER2->ROUTE |= TIMER_ROUTE_CC0PEN diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp index 8bac61bc6fbb934de384426a4a16bb1bee214392..cbead9978158f4708b619199e9ac5714ff1e7af6 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp @@ -298,7 +298,7 @@ void Transceiver::sendAt(const void* pkt, int size, long long when) //while the cc2520 requires the turnaround from STXON to sending if(timer.absoluteWaitTrigger(when-timer.ns2tick(turnaround))==true) { - //See diagram on page 69 of datasheet + //See diagram on page 69 of datasheet commandStrobe(CC2520Command::SFLUSHTX); throw runtime_error("Transceiver::sendAt too late to send"); } diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp index d0c77f4b3e498442b0babc87db153a031d06cedb..4cb85a0bf89a3d5455ba09bcf00499f74103eeed 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp @@ -55,7 +55,6 @@ bool TransceiverTimer::absoluteWaitTimeoutOrEvent(long long tick){ return true; } - b.enableCC0Interrupt(false); b.enableCC0InterruptTim2(true); do {