Update main.c

Initialize GPIO Port B
This commit is contained in:
Uttam Bhavimani Bhavimani 2024-10-28 22:51:49 +05:30
parent 3329c47d5d
commit d110658f12
1 changed files with 21 additions and 0 deletions

21
main.c
View File

@ -17,3 +17,24 @@ void GPIO_PORT_F_init(void)
GPIO_PORTF_IEV_R = 0x00; // INTERRUPT EVENT FALLING
GPIO_PORTF_IM_R |= 0x11; // UNMASK INTERRUPT
}
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 FUNCTIONALITY
UART1_CTL_R &= ~0x01; // DISABLE UART1 DURING SETUP
UART1_IBRD_R = 104; // SET INTEGER PART OF BAUD RED FOR 9600 BAUD FORMULA:
UART1_FBRD_R = 11; // SET FRACTIONAL PART OF BAUD RATE
UART1_LCRH_R = 0x62; // SET 8-BIT, ODD PARITY, STOP BIT-1
UART1_CC_R = 0x00; // USE SYSTEM CLOCK
UART1_CTL_R |= 0x301; // ENABLE UART1, RX AND TX
}