Hello,
Alex: I used the uart_init method from your samd10 as a reference and I guess I forgot to link the genclk to a source with the GENCTRL register.
I added:
GCLK->CLKCTRL.reg |= GCLK_CLKCTRL_ID(SERCOM1_GCLK_ID_CORE) | GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN(GCLK_CLKCTRL_GEN_GCLK1_Val);
And now I have output on the data out pin, but for some reason not the SCLK pin. I haven't had too much time this weekend to devote to debugging this, but I will be able to spend some time this week.
ajb: Yes, my baud calculation is wrong. The baud calculation is a point of confusion for me. The data sheet specifies that for synchronous mode the calculation should result in an 8-bit number, however my calculation results in a 9-bit number. The equation they give is BAUD = (fref / (2 * fbaud)) where fref is the frequency from the GCLK (8MHz in this case), fbaud is the baud rate as a frequency I think and BAUD is the value to be put into the register which would give the corresponding baud rate.
My fref is 8MHz if as I have disabled the prescaler. The baud I would like is 9600 which equates to 9600Hz. so plugging in the numbers gives 417(rounded). If I'm not mistaken, the solution is to to divide this gclk by 8.
I added:
uint32_t br = (uint16_t)((F_CPU/8)/(baud*2)) - 1;
GCLK->GENDIV.reg = GCLK_GENDIV_ID(GCLK_CLKCTRL_GEN_GCLK1_Val) | GCLK_GENDIV_DIV(8);