Skip to content

Enable LPC8xx usart when configuring it #1266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,18 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
default:
break;
}

obj->uart->CFG = (data_bits << 2)

// First disable the the usart as described in documentation and then enable while updating CFG

// 24.6.1 USART Configuration register
// Remark: If software needs to change configuration values, the following sequence should
// be used: 1) Make sure the USART is not currently sending or receiving data. 2) Disable
// the USART by writing a 0 to the Enable bit (0 may be written to the entire register). 3)
// Write the new configuration value, with the ENABLE bit set to 1.
obj->uart->CFG &= ~(1 << 0);

obj->uart->CFG = (1 << 0) // this will enable the usart
| (data_bits << 2)
| (paritysel << 4)
| (stop_bits << 6);
}
Expand Down
12 changes: 11 additions & 1 deletion libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,17 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
break;
}

obj->uart->CFG = (data_bits << 2)
// First disable the the usart as described in documentation and then enable while updating CFG

// 24.6.1 USART Configuration register
// Remark: If software needs to change configuration values, the following sequence should
// be used: 1) Make sure the USART is not currently sending or receiving data. 2) Disable
// the USART by writing a 0 to the Enable bit (0 may be written to the entire register). 3)
// Write the new configuration value, with the ENABLE bit set to 1.
obj->uart->CFG &= ~(1 << 0);

obj->uart->CFG = (1 << 0) // this will enable the usart
| (data_bits << 2)
| (paritysel << 4)
| (stop_bits << 6);
}
Expand Down