make it work
apparently divider values of != 1 for the ncn8025 cause issues, using
the same clkgen for the uart + arbitrary clock values with divider 1
appears to work
Change-Id: If9e79e255b0fcaaa8a3489ea659f33e9b4aa3cc1
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index 971b805..32990b7 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -54,6 +54,7 @@
static void _SIM_error_cb(const struct usart_async_descriptor *const descr){
volatile uint32_t status = hri_sercomusart_read_STATUS_reg(descr->device.hw);
volatile uint32_t data = hri_sercomusart_read_DATA_reg(descr->device.hw);
+ volatile uint32_t errrs = hri_sercomusart_read_RXERRCNT_reg(descr->device.hw);
OSMO_ASSERT(0 == 1)
}
@@ -142,12 +143,12 @@
/** possible clock sources for the SERCOM peripheral
* warning: the definition must match the GCLK configuration
*/
-static const uint8_t sercom_glck_sources[] = {GCLK_PCHCTRL_GEN_GCLK2_Val, GCLK_PCHCTRL_GEN_GCLK4_Val, GCLK_PCHCTRL_GEN_GCLK6_Val};
+static const uint8_t sercom_glck_sources[] = {GCLK_PCHCTRL_GEN_GCLK5_Val};
/** possible clock frequencies in MHz for the SERCOM peripheral
* warning: the definition must match the GCLK configuration
*/
-static const double sercom_glck_freqs[] = {100E6 / CONF_GCLK_GEN_2_DIV, 100E6 / CONF_GCLK_GEN_4_DIV, 120E6 / CONF_GCLK_GEN_6_DIV};
+static const double sercom_glck_freqs[] = {100E6 / CONF_GCLK_GEN_5_DIV};
/** the GCLK ID for the SERCOM SIM peripherals
* @note: used as index for PCHCTRL
@@ -245,7 +246,7 @@
}
// calculate desired frequency
- uint32_t freq = 20000000UL; // maximum frequency
+ uint32_t freq = 4000000UL; // maximum frequency
switch (clkdiv) {
case SIM_CLKDIV_1:
freq /= 1;
@@ -295,7 +296,7 @@
usart_async_enable(usa_pd);
// set USART baud rate to match the interface (f = 2.5 MHz) and card default settings (Fd = 372, Dd = 1)
- slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_8, ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
+ slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_1, ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
return 0;
}
@@ -363,7 +364,7 @@
// set USART baud rate to match the interface (f = 2.5 MHz) and card default settings (Fd = 372, Dd = 1)
if(arg)
- slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_8, ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
+ slot_set_isorate(cuart->u.asf4.slot_nr, SIM_CLKDIV_1, ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
ncn8025_set(cuart->u.asf4.slot_nr, &settings);
break;