Hello i am trying to control two LEDs with the switches located at PF0 and PF4, when i try to run my code only one switch works correctly, that is LED lights up when i press SW2,
the other LED stays lit for the whole time. I
I am confused whether the problem is in my code or circuit.
Below is the code, i want to read from PF0 and PF4 and write to PD0 and PD1.
Thanks
_______________________________________________________________________________________________________________________________________________
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "inc/tm4c123gh6pm.h"
#include <stdio.h>
volatile uint32_t code;
void PORTD_Init (void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD))
{};
GPIO_PORTD_DEN_R= 0x03;
}
void PORTF_Init (void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF)){};
GPIO_PORTF_LOCK_R= 0x4C4F434B;
GPIO_PORTF_CR_R=0x11;
GPIO_PORTF_PUR_R=0x11;
GPIO_PORTF_DEN_R=0x11;
}
int main(void)
{
PORTD_Init();
PORTF_Init();
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0|GPIO_PIN_1);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_4);
while(1)
{
code=GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_4);
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_0|GPIO_PIN_1,code);
}
}