Hi,
I have the following code: (It's part of the bigger piece of course)
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I have the following code: (It's part of the bigger piece of course)
hii markel
highlighted piece of code is not working. please have a look.
#include<tm4c123gh6pm.h>
#include<stdbool.h>
#include<stdint.h>
#include<interrupt.h>
#include<sysctl.h>
#include<gpio.h>
#include<hw_memmap.h>
#include<timer.h>
volatile unsigned long u,p,q;
void delay(int a);
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlDelay(3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlDelay(3);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6|GPIO_PIN_7);
while(1)
{
q= GPIOPinRead(GPIO_PORTA_BASE,GPIO_PIN_7)& 0x80;
p= GPIOPinRead(GPIO_PORTA_BASE,GPIO_PIN_6)& 0x40;
if(p==0x40) //button pressed
{
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_2,true);
delay(300000);
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_2,false);
delay(300000);
}
else if(q==0x80) //button pressed
{GPIO_PORTD_DATA_R |= 0x02;
delay(300000);
GPIO_PORTD_DATA_R &= ~(0x02);
delay(300000);
}
else //button not pressed
{
GPIO_PORTD_DATA_R |= 0x08;
delay(300000);
GPIO_PORTD_DATA_R &= ~(0x08);
delay(300000);
}
}
}
void delay(int a){
for(u = 0; u < a; u++)
{}}
regards
prashant