Hello,
I am working on getting an LCD display to work with my Tive Tm4C , I have initialised PortA pins 2&3 which I will be using for the RS and enable line and I have initialised PortB pins 2,3,4,5 for the DB lines of the LCD as I am using it in 4-bit mode.
My problem comes when I used both ports together, for example to check they were working fine I had a simple function light up some LEDS, this worked fine for PortA, I went ahead and initialised PortB and tested it the same way and it was fine. However, if I initialise both ports and get them to output my programme crashes.
#define GPIO_PORTA_DATA_R (*(( volatile unsigned long*)0x400043FC))
#define SYSCTL_RCG2_R (*(( volatile unsigned long*)0X400FE108))
#define GPIO_PORTA_AMSEL_R (*(( volatile unsigned long*)0X40004528))
#define GPIO_PORTA_PCTL_R (*(( volatile unsigned long*)0X4000452C))
#define GPIO_PORTA_DIR_R (*(( volatile unsigned long*)0X40004400))
#define GPIO_PORTA_AFSEL_R (*(( volatile unsigned long*)0X40004420))
#define GPIO_PORTA_DEN_R (*(( volatile unsigned long*)0X4000451C ))
#define GPIO_PORTB_DATA_R (*(( volatile unsigned long*)0X400053FC))
#define GPIO_PORTB_AMSEL_R (*(( volatile unsigned long*)0X40005528))
#define GPIO_PORTB_PCTL_R (*(( volatile unsigned long*)0X4000552C))
#define GPIO_PORTB_DIR_R (*(( volatile unsigned long*)0X40005400))
#define GPIO_PORTB_AFSEL_R (*(( volatile unsigned long*)0X40005420))
#define GPIO_PORTB_DEN_R (*(( volatile unsigned long*)0X4000551C ))
//GPIO definitions
#define PA2 (*(( volatile unsigned long*)0x40004010)) //Connected to EN
#define PA3 (*(( volatile unsigned long*)0x40004020)) //Connected to RS
#define PB (*(( volatile unsigned long*)0x400050F0)) // Pins PB2,PB3,PB4,PB5 connected to DB4,DB5,DB6,DB7
void PortA_Init(void) {
volatile unsigned long delay;
SYSCTL_RCG2_R |=0x00000001; //set bit 0 for clock on port A
delay = SYSCTL_RCG2_R; //delay
GPIO_PORTA_AMSEL_R &=~ 0x0000000c; //disable analogue function
GPIO_PORTA_PCTL_R &=~0x0000FF00; //GPIO clear bits 8-11 for PA2 and 12-15 for PA3
GPIO_PORTA_DIR_R |=0x0c; //set bits 2 and 3
GPIO_PORTA_AFSEL_R &=~0x0c; //no alternate function
GPIO_PORTA_DEN_R |=0x0c; //enable pins PA2 and PA3
}
void PortB_Init(void) {
volatile unsigned long delay;
SYSCTL_RCG2_R=0x00000002; //set bit 1 for clock on port B
delay = SYSCTL_RCG2_R; //delay
GPIO_PORTB_AMSEL_R &=~ 0x0000003C; //disable analogue function clear bits 2,3,4,5
GPIO_PORTB_PCTL_R &=~0x00FFFF00; //GPIO clear bits 8-11 for PB2 12-15 for PB3 16-19 PB4 20-23 PB5
GPIO_PORTB_DIR_R |=0x3c; //set bits 2,3,4,5
GPIO_PORTB_AFSEL_R &=~0x3c; //no alternate function
GPIO_PORTB_DEN_R |=0x3c; //enable pins PA2 and PA3
}
Also a link to the project files here