Skip to content

Commit 61ce8ac

Browse files
committed
Enable LPC1549 usart when configuring it
1 parent e1b89d4 commit 61ce8ac

File tree

1 file changed

+12
-2
lines changed
  • libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX

1 file changed

+12
-2
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,18 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
211211
default:
212212
break;
213213
}
214-
215-
obj->uart->CFG = (data_bits << 2)
214+
215+
// First disable the the usart as described in documentation and then enable while updating CFG
216+
217+
// 24.6.1 USART Configuration register
218+
// Remark: If software needs to change configuration values, the following sequence should
219+
// be used: 1) Make sure the USART is not currently sending or receiving data. 2) Disable
220+
// the USART by writing a 0 to the Enable bit (0 may be written to the entire register). 3)
221+
// Write the new configuration value, with the ENABLE bit set to 1.
222+
obj->uart->CFG &= ~(1 << 0);
223+
224+
obj->uart->CFG = (1 << 0) // this will enable the usart
225+
| (data_bits << 2)
216226
| (paritysel << 4)
217227
| (stop_bits << 6);
218228
}

0 commit comments

Comments
 (0)