Skip to content

Commit ac6a6b8

Browse files
Neil Tuttlecy-opm
authored andcommitted
TARGET_PSOC6: Fix incorrect serial clock divider
If the board-specific initialization code configures the serial port to use an 8-bit divider, the serial_init_clock function would configure the 16-bit divider with the same index instead of the intended 8-bit divider.
1 parent 20c2734 commit ac6a6b8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/serial_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,24 +305,25 @@ static cy_en_sysclk_status_t serial_init_clock(serial_obj_t *obj, uint32_t baudr
305305
}
306306
}
307307
} else {
308+
/* Divider already allocated and connected to the SCB block */
308309
status = CY_SYSCLK_SUCCESS;
309310
}
310311

311312
if (status == CY_SYSCLK_SUCCESS) {
312313
Cy_SysClk_PeriphDisableDivider(obj->div_type, obj->div_num);
313314

314315
/* Set baud rate */
315-
if (obj->div_type == CY_SYSCLK_DIV_16_5_BIT) {
316+
if ((obj->div_type == CY_SYSCLK_DIV_16_5_BIT) || (obj->div_type == CY_SYSCLK_DIV_24_5_BIT)) {
316317
/* Get fractional divider */
317318
uint32_t divider = divider_value(baudrate * UART_OVERSAMPLE, 5U);
318319

319-
status = Cy_SysClk_PeriphSetFracDivider(CY_SYSCLK_DIV_16_5_BIT,
320+
status = Cy_SysClk_PeriphSetFracDivider(obj->div_type,
320321
obj->div_num,
321322
FRACT_DIV_INT(divider),
322323
FRACT_DIV_FARCT(divider));
323324
} else {
324325
/* Get integer divider */
325-
status = Cy_SysClk_PeriphSetDivider(CY_SYSCLK_DIV_16_BIT,
326+
status = Cy_SysClk_PeriphSetDivider(obj->div_type,
326327
obj->div_num,
327328
divider_value(baudrate * UART_OVERSAMPLE, 0));
328329
}

0 commit comments

Comments
 (0)