Group05_Lab05/lab5.c

40 lines
1.2 KiB
C
Raw Normal View History

2024-09-16 10:49:53 +05:30
#include <stdint.h>
#include <stdbool.h>
#include "tm4c123gh6pm.h"
int main(void)
{
SYSCTL_RCGC2_R |= 0x00000020; /* enable clock to GPIOF */
GPIO_PORTF_LOCK_R = 0x4C4F434B; /* unlock commit register */
GPIO_PORTF_CR_R = 0x11; /* make PORTF0 PORTF4 CONFIGURABLE*/
GPIO_PORTF_DEN_R = 0x1F; /* set PORTF pins 5 pins*/
GPIO_PORTF_DIR_R = 0x0E; /* set PORTF0 PORTF4 pin as input user switch pin */
GPIO_PORTF_PUR_R = 0x11; /* PORTF4 PORT0 is pulled up */
2024-09-19 10:21:37 +05:30
NVIC_EN0_R |= (1<<30); //Starting NVIC as all the interrupt goes through it
GPIO_PORTF_IM_R = 0x00; /*Masking the ports*/
2024-09-17 12:17:24 +05:30
GPIO_PORTF_IS_R = 0x00;
2024-09-19 10:21:37 +05:30
GPIO_PORTF_IBE_R = 0x00;
2024-09-16 10:51:33 +05:30
GPIO_PORTF_IEV_R = 0x00; /*detects the falling edge of the switch*/
2024-09-19 10:21:37 +05:30
GPIO_PORTF_ICR_R = 0x11;
GPIO_PORTF_IM_R = 0x11;
2024-09-16 10:49:53 +05:30
2024-09-17 12:17:24 +05:30
while(1)
{
2024-09-19 10:21:37 +05:30
//GPIO_PORTF_DATA_R = 0x02;
2024-09-17 15:41:44 +05:30
}
2024-09-19 10:21:37 +05:30
}
2024-09-17 15:41:44 +05:30
void GPIOIntHandler(void)
{
2024-09-19 10:21:37 +05:30
int i=0;
for(i=0;i<1000;i++);
if((GPIO_PORTF_DATA_R & 0x11)== 0x11){}
else
{
2024-09-19 22:28:53 +05:30
GPIO_PORTF_DATA_R ^= 0x02;
2024-09-19 10:21:37 +05:30
}
GPIO_PORTF_ICR_R = 0x11;
2024-09-17 12:17:24 +05:30
}