Hello TI E2E Community!
Since this is my first post on this forum, please don't be mad for possible missing information and just ask!
My problem is, that I'm using the TM4C123GH6PMs UART0 and UART4 to have a connection to a bluetooth module and a PC, but im struggling to send/receive data.
My code is the following (for UART4):
const int idelay = 1000; //for delay unsigned long int* RCGCUART; //address of Rcgcuart unsigned long int* RCGCGPIO; //.. unsigned long int* GPIOAFSEL; //.. unsigned long int* GPIOPCTL; //.. unsigned long int* UARTCTL; //.. unsigned long int* UARTIBRD; //.. unsigned long int* UARTFBRD; //.. unsigned long int* UARTLCRH; //.. unsigned long int* PPUART; //.. //1.Enable UART via RCGCUART Register page 333 //Base address 0x400F.E000 is a System Control Register as seen on page 97 //Offset address 0x618 Adress for the RCGCUART Register //Addition gives the adresse: 0x400F.E618 //to set the UART4 the fifth Bit must be set. RCGCUART = 0x400FE618; //*RCGCUART &= 0xEF; // Disable UART4 *RCGCUART |= 0x10; //Enable UART4 delay_ms(idelay); //2.Enable the clock to the appropiate GPIO module via RCGCGPIO page 328 //The Base address is 0x400F.E000 //The offset address is 0x608 //That gives: 0x400F.E608 //PORTC is the third Bit so : 0x4 = 0b100 RCGCGPIO = 0x400FE608; *RCGCGPIO |= 0x4; delay_ms(idelay); //3.Setting the GPIO AFSEL for the appropiate PINs //GPIO PORTC APB Base is on 0x4000.6000 //Offset is 0x420 -> that gives in total 0x4000.6420 //PORTC4/5 Uart4 is on Pin 36/35 GPIOAFSEL = 0x40006420; *GPIOAFSEL |= 0x30; delay_ms(idelay); //4.Configure Current level and slew rate control //2mA default //Slew rate default no slew rate control //5.Configure PMCn fields in the GPIOPCTL register to asign the UART Signals to the appropiate pin //Base of the GPIOPCTL register is 0x4000.6000 for PORTC APB //The offset is 0x52C //That gives 0x4000652C //Write the appropiate value for UART4 into the Pin4 and Pin5 fields. Should be 0x2; GPIOPCTL = 0x4000652C; *GPIOPCTL |= 0x00110000; delay_ms(idelay); //Configuration of the UART: //1.Disable UART //Disabling by resetting UARTEN in the UARTCTL register //Base address is 0x4001.0000 //The offset address is 0x030 //UARTEN is the first Bit UARTCTL = 0x40010030; *UARTCTL &= 0xFFFFFFFE; *UARTCTL |= 0x300; delay_ms(idelay); //2.BAUDRATE //BRD = 16000000 / (16 * 115200) = 8,6805° //UARTFBRD = integer(0,6805 * 64 + 0.5) = 44 //UARTIBRD base is on 0x4001.0000 //and offset is 0x024 //UARTFBRD base is on 0x4001.0000 //and offset is 0x028 UARTIBRD = 0x40010024; *UARTIBRD |= 0x8; UARTFBRD = 0x40010028; *UARTFBRD |= 0x2C; delay_ms(idelay); //3.data length, parity and stop bit //This is set in the UARTLCRH register //The base address is 0x4001.0000 //The offset address is 0x02C // Bit 5 and 6 are the data length. 0x3 is 8 bits. // no parity and 1 stop bit default UARTLCRH = 0x4001002C; *UARTLCRH |= 0x60; //0b01100000 delay_ms(idelay); //4.Enable the UART4 again UARTCTL = 0x40010030; *UARTCTL |= 0x00000001; delay_ms(idelay); //Transmit on UARTDR register //Base address for UART4 0x4001.0000 //offset address is 0x00 unsigned long int* UARTDR = 0x40010000; *UARTDR |= 0x41; //Send Letter A
The sending pin always stays on high (idle) - measured by an oszilloscope.
I also tried to receive, using an interrupt - I get an interrupt, but the Data Register won't change it's state to anything - staying at 0x00000000 all the time!
Really struggling with that, I'd hope someone could help me!
Best regards,
Fabian