Dear all,
I need to drive clock signals on two different ports (PB0, PA0) using NANO Every (4809). I followed using TCA application note and got clock on PA0.
I tried to route/port mux to PB0 but it seems wrong. have goe through many app notes and data sheet. Many thanks for any hint or guidance.!
best regards,
Mira
code from app note:
#define PERIOD_EXAMPLE_VALUE (0x01A0)
#define DUTY_CYCLE_EXAMPLE_VALUE (0x00D0)
#include <avr/io.h>
/*Using default clock 3.33MHz */
void TCA0_init(void);
void PORT_init(void);
void TCA0_init(void)
{
/* set waveform output on PORT A */
PORTMUX.TCAROUTEA = PORTMUX_TCA0_PORTA_gc;
TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm /* enable compare
channel 0 */
| TCA_SINGLE_WGMODE_DSBOTTOM_gc; /* set dual-slope PWM
mode */
/* disable event counting */
TCA0.SINGLE.EVCTRL &= ~(TCA_SINGLE_CNTEI_bm);
/* set PWM frequency and duty cycle (50%) */
TCA0.SINGLE.PERBUF = PERIOD_EXAMPLE_VALUE;
TCA0.SINGLE.CMP0BUF = DUTY_CYCLE_EXAMPLE_VALUE;
TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV4_gc /* set clock source
(sys_clk/4) */
| TCA_SINGLE_ENABLE_bm; /* start timer */
}
void PORT_init(void)
{
/* set pin 0 of PORT A as output */
PORTA.DIR |= PIN0_bm;
}
int main(void)
{
PORT_init();
TCA0_init();
/* Replace with your application code */
while (1)
{
;
}
}