Tool/software:
Dear TI-support team,
I am a beginner in baremetal programming and I am trying to make an LED blink using the SK-TDA4VM board. I have an LED connected to physical pin 16, which, according to the user guide of the board, corresponds to GPIO0_5.
I am having difficulties getting the LED to light up. My code runs without any issues, but the LED does not turn on. It is based on the addresses of the GPIO0_5 registers, but I am not sure if I fully understood the documentation (Technical Reference Manual), so I might be using incorrect addresses. I have tried several addresses, but nothing has worked so far.
Additionally, I thought the issue might be related to the clock, so I added the PLL configuration to my code, but still, the LED does not turn on.
Here is the code I am using:
#include <stdint.h> // For the type uint32_t #define GPIO0_BASE_ADDR 0x00620000 #define GPIO_SETDATA_OFFSET 0x18 // Offset for the SET_DATA register of bank 0 #define GPIO_CLRDAT_OFFSET 0x1C // Offset for the CLR_DATA register of bank 0 #define GPIO_DIR_OFFSET 0x10 // Offset for the DIR register of bank 0 #define GPIO0_5 (1 << 5) // Pin 5 (bit 5 of the register) #define PLLCTRL0_BASE_ADDR 0x00410100 // Address of the PLLCTRL0 register #define PLLEN_BIT (1 << 0) // Bit 0: PLL Mode Enable int main(void) { // 0. Enable PLL Mode volatile uint32_t *pllctrl0 = (uint32_t *)PLLCTRL0_BASE_ADDR; *pllctrl0 |= 1; // Set bit 0 to enable PLL Mode // Define pointers for bank 0 registers volatile uint32_t *gpio0_dir = (uint32_t *)(GPIO0_BASE_ADDR + GPIO_DIR_OFFSET); volatile uint32_t *gpio0_setdata = (uint32_t *)(GPIO0_BASE_ADDR + GPIO_SETDATA_OFFSET); volatile uint32_t *gpio0_clrdata = (uint32_t *)(GPIO0_BASE_ADDR + GPIO_CLRDAT_OFFSET); // 1. Configure GPIO0_5 as output *gpio0_dir &= ~GPIO0_5; // Set bit 5 to 0 to configure as output while (1) { // 2. Turn on the LED (GPIO0_5 = 1) *gpio0_setdata = GPIO0_5; // Set pin 5 (turns on the LED) // Delay to see the LED blink for (uint32_t i = 0; i < 500000; i++); // 3. Turn off the LED (GPIO0_5 = 0) *gpio0_clrdata = GPIO0_5; // Clear pin 5 (turns off the LED) // Delay to see the LED blink for (uint32_t i = 0; i < 500000; i++); } return 0; }
I am using arm-none-eabi-gcc to compile for the R5 core of the main domain and Code Composer Studio (CCS), along with an XDS110, just to run the already compiled code and debug.
If you could assist me, I would greatly appreciate it!
Thank you in advance for your help!