Initialize PORTB for UART1 with 9600 baud rate
This commit is contained in:
parent
1a6248ef11
commit
e52ff2bad3
19
main.c
19
main.c
|
@ -19,4 +19,23 @@ void GPIO_PORT_F_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GPIO_PORT_B_init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
SYSCTL_RCGCGPIO_R |= 0x02; // ENABLE CLOCK FOR GPIOB
|
||||||
|
SYSCTL_RCGCUART_R |= 0x02; // ENABLE CLOCK FOR UART1
|
||||||
|
|
||||||
|
GPIO_PORTB_DEN_R |= 0x03; // DIGITAL ENABLE FOR PB0 AND PB1
|
||||||
|
GPIO_PORTB_AFSEL_R |= 0x03; // ENABLE ALTERNATE FUNCTION ON PB0,PB1
|
||||||
|
|
||||||
|
GPIO_PORTB_PCTL_R = (GPIO_PORTB_PCTL_R & 0xFFFFFF00) | 0x00000011; // Set PB0, PB1 for UART
|
||||||
|
|
||||||
|
UART1_CTL_R &= ~0x01; // DISABLE UART1 DURING SETUP
|
||||||
|
UART1_IBRD_R = 104; // Set integer part of baud rate (for 9600 baud at 16 MHz clock)
|
||||||
|
UART1_FBRD_R = 11; // Set fractional part of baud rate
|
||||||
|
UART1_LCRH_R = 0x62; // 8-bit, odd parity, 1 stop bit
|
||||||
|
UART1_CC_R = 0x00; // Use system clock
|
||||||
|
|
||||||
|
UART1_CTL_R |= 0x301; // Enable UART1, RX, and TX
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue