Basic C Language Program for Texas Instrument Board CM4C123G Comment the code on
ID: 3883090 • Letter: B
Question
Basic C Language Program for Texas Instrument Board CM4C123G
Comment the code on all the operations the program is doing. I commented most of it but cant figure out the rest.
#include <stdint.h> //all the header files are included here
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
int main(void) //start of the program
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); //set the clock frequency
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); //configure gpio pins
while(1)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x08); //write to gpio LED
SysCtlDelay(20000000); //delay time for LED on
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);
SysCtlDelay(20000000); //delay time for LED off
}
}
1.4.2 C Program Code to Blink an Onboard LED #include #include #include #include #include #include #include #include "inc/hw-types.h" "inc/hw memmap.h" "driver!ib/sysct1.h" "drive rlib/pin-map.h" "drive rlib/debug.h" "driverlib/gpio.h" int main (void) SysCticlockSet (SYSCTL SYSDIV51 SYSCTL-USE-PLLI SYSCTL XTAL 16Mazl SYSCTL_OSC MAIN) SysCtlPeripheralEnable (SYSCTL PERIPH GPIOF) GPIOPinTypeGP1OOutput (GPIO PORTF BASE, GPIO PIN 11GPIO PIN 2 GPIO PIN 3) To Bink an Onboard LED INSTRUMENTS www.ti.com Proced while (1) GPIOPinWeite (GPIO_PORTF_BASE, GPIO PIN 1IGPIO PIN 2IGPIO PIN 3. 0x08) SysCt1Delay (20000000) GPIOPinWrite (GP GPIO PIN_2IGPIO PIN 3, 0x00) SysCt1Delay (20000000) TO PORTF BASE, GPTO PIN1Explanation / Answer
#include <stdint.h> //all the header files are included here
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
int main(void) //start of the program
{
//Set the clock
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); //set the clock frequency
// Enable the peripherals used by this program.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//configure gpio pins
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); //configure gpio pins
while(1)
{
//write to gpio LED
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x08); //write to gpio LED
//delay time for LED on
SysCtlDelay(20000000); //delay time for LED on
//write to gpio LED
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);//write to gpio LED
//delay time for LED off
SysCtlDelay(20000000); //delay time for LED off
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.