I have been working with the Curiosity Nano, and have been attempting to use a USART in master SPI mode, the event system, and CCL to create the drive waveform for the WS2812B LEDs. I have done this successfully on the ATxmega32E5, but the AVR128DA48 is quite different, especially in the XCL / CCL block. The AVR CCL has no programmable one-shot timer blocks, so I am trying to use one of the TCBn timers in one-shot mode.
The idea is to use the timer to create a fixed-time window triggered by the XCK rising edge, which I can use with the CCL to create a 375ns always-high state, followed by another 375ns state which is 0 or 1, depending upon the value of the TXD bit, and finally, a low state that remains low until the next XCK rising edge starts the whole sequence over. I will use this one-shot time window with the CCL to create the final output waveform. The diagram below illustrates my goal.
I have verified the USART SPI TXD and XCK output. Event channel 1 is assigned to USART XCK. I configured EVOUTB as an event user and verified the XCK signal is present on EVOUTB; it looks virtually identical to the signal on the XCK output pin. Unfortunately, I am not having success getting TCB1 to operate as a one-shot timer.
I configured TCB1 for one-shot operation, TCMP = 9 counts, 24MHz clock, and enabled the WO output. I also wrote the TCMP count value to the CNT register, so the timer will not start when it is first enabled. I set it as an event user of the XCK event. If I set TCB1 output as asynchronous trigger, the WO output on PA3 goes high on the first rising edge of XCK, but it remains high indefinitely. If I set TCB1 output as synchronous, the WO output remains low. In either event, there is no evidence that TCB1 actually counted, as the interrupt flags remain 0.
If I leave the CNT register at zero when I enable TCB1, the timer starts and counts up to the terminal count, and stops. It still doesn't seem to respond to the event trigger.
Has anyone had success with what I am attempting? I would appreciate any suggestions. Thank you!