/*Youtube Channel: AJAYNIRMAL RANGANATHAN * Button control in TM4C123 launchpad */#include<stdint.h>#include"tm4c123gh6pm.h"uint32_tvalue;intmain(void){SYSCTL_RCC_R|=0x02400540;// Configure system clockSYSCTL_RCGCGPIO_R|=SYSCTL_RCGCGPIO_R5;//System PortF peripheral clock enableGPIO_PORTF_LOCK_R|=0x4C4F434B;//Unclock CodeGPIO_PORTF_CR_R|=0x00000001;//Commit RegisterGPIO_PORTF_DEN_R|=0x000000FF;// enable the pins of port as DIGITALGPIO_PORTF_DIR_R|=0x00000004;//Configure the ports for LED & switchGPIO_PORTF_PUR_R|=0x00000001;//Configure Pull-up resistor on PF0while(1){value=GPIO_PORTF_DATA_R&0x00000001;//read the status of switchif(value==0x0000000){GPIO_PORTF_DATA_R=0x00000004;//on board LED on}else{GPIO_PORTF_DATA_R=0x00000000;//on board LED off}}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.