[go: up one dir, main page]

0% found this document useful (0 votes)
51 views3 pages

Include

The document includes header files for GPIO and SysCtl peripheral libraries. It sets up GPIO pins on port F to output alternating 1Hz and 2Hz signals by toggling the pin states and inserting delays. The main loop continuously toggles the pin states to generate the timing signals.

Uploaded by

Dat Nguyen Thanh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

Include

The document includes header files for GPIO and SysCtl peripheral libraries. It sets up GPIO pins on port F to output alternating 1Hz and 2Hz signals by toggling the pin states and inserting delays. The main loop continuously toggles the pin states to generate the timing signals.

Uploaded by

Dat Nguyen Thanh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include "inc/hw_memmap.

h“
#include "inc/hw_types.h“
#include "driverlib/gpio.c“
#include "driverlib/sysctl.h“
unsigned int i;
int main()
{
//Enable GPIO Port F
SysCtlPeripheralEnable(SYSCTL_ PERIPH_GPIOF);
// Set system clock to run at 50 MHz
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ)
//Pin PF2 has 1Hz clock singal
//Pin PF1 has 2Hz clock singal
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_1| GPIO_PIN_2);

while(1)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_PIN_2 );
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_PIN_1 );
SysCtlDelay(SysCtlClockGet() / (4*3); //delay 0.25s
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2, 0);
SysCtlDelay(SysCtlClockGet() / (4*3); //delay 0.25s
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1, 0);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_PIN_2 );
SysCtlDelay(SysCtlClockGet() / (4*3); //delay 0.25s
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2, 0);
SysCtlDelay(SysCtlClockGet() / (4*3); //delay 0.25s
}
}

#include "inc/hw_memmap.h“
#include "inc/hw_types.h“
#include "driverlib/gpio.c“
#include "driverlib/sysctl.h“
Int main()
{
SysCtlPeripheralEnable(SYSCTL_ PERIPH_GPIOF);
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1| GPIO_PIN_2|
GPIO_PIN_0| GPIO_PIN_3| GPIO_PIN_4| GPIO_PIN_5| GPIO_PIN_6|
GPIO_PIN_7);
uint8_t count = 0;
while (1) {
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1| GPIO_PIN_2| GPIO_PIN_0|
GPIO_PIN_3| GPIO_PIN_4| GPIO_PIN_5| GPIO_PIN_6| GPIO_PIN_7, count
);
count ++;
If( count ==0 ){
Count = 0x00;
}
SysCtlDelay ( SysCtlClockSet () / 3)

}
#include <stdint.h>

#include <stdbool.h>

#include "inc/hw_memmap.h"

#include "inc/hw_types.h"

#include "driverlib/gpio.h"

#include "driverlib/pin_map.h"

#include "driverlib/sysctl.h"

#include "driverlib/uart.h"
Int main() {
uint32_t ui32ADC0Value[4];

volatile uint32_t ui32TempAvg;

volatile uint32_t ui32TempValueC;


SysCtlSet (SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
| SYSCTL|XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//Set up UART
SysCtlPeripheralEnable (SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA0_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN0 | GPIO_PIN1);
UARTConfigSetExpClt(UART0_BASE, SysCtlClockGet(), 115200,
UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//Set up ADC
SysCtlPeripheralEnable (SYSCTL_PERIPH_ADC0);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|
ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 1)
while(1)

ADCIntClear(ADC0_BASE, 1);

ADCProcessorTrigger(ADC0_BASE, 1);

while(!ADCIntStatus(ADC0_BASE, 1, false))

ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);

ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] +


ui32ADC0Value[3] + 2)/4;

ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;

snprintf(tempstring, sizeof(tempstring), "%d\n", ui32TempValueF);


UARTCharPut(UART0_BASE, tempstring[0]);
UARTCharPut(UART0_BASE, tempstring[1]);
UARTCharPut(UART0_BASE, tempstring[2]);

}
}

You might also like