Tool/software:
HI
I am trying to switch on and off an external LED by using the code below. The circuit connection to external LED is GPIO0 ----> LED1 ----> Resistor ----> GND. GPIO0 is the first pin of the board, GND is the ground of the board and Resistor = 330ohm. Though the register values within GPIO0 is toggling between 0 and 1.Can you please help why its not switching off and off external LED.
Kind Regards
Sana
#include "F28x_Project.h" // Device header file
void main(void)
{
// Step 1: Initialize system control, clocks, and peripherals
InitSysCtrl();
// Step 2: Disable interrupts during configuration
DINT;
// Step 3: Initialize GPIO for LEDs
InitGpio();
// Configure GPIO pins as outputs
EALLOW; // Enable protected registers
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // GPIO0 as output
EDIS; // Disable protected registers
// Step 4: Turn off all LEDs initially
GpioDataRegs.GPACLEAR.bit.GPIO0 = 1;
while(1) // Infinite loop
{
// Turn on GPIO0 LED and wait
GpioDataRegs.GPASET.bit.GPIO0 = 1;
DELAY_US(1000000); // 1 second delay
GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // Turn off LED
}
}