#define PWM_FREQUENCY 55
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/pwm.h"
#include "driverlib/adc.h"
uint32_t sysclock;
uint32_t input_value;
uint32_t i;
int sample_val[100],pinVal,pinVal1;
extern unsigned long ulADC0Value[100];
//PG1 is the PWM Pin
void main()
{
// 600KHz Signal on PE5
// float PWM_FREQ;
// float CPU_FREQ;
// float pwm_word;
// PWM_FREQ = 1434; //
// CPU_FREQ = 120000000;
// pwm_word = (1/PWM_FREQ)*CPU_FREQ;
//sysclock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), CPU_FREQ);
SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_5);
GPIOPinConfigure(GPIO_PE5_M0PWM5);
PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_NO_SYNC);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 200); //Setting for 200KHz
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 200); // 50% Duty Cycle
PWMGenEnable(PWM0_BASE, PWM_GEN_2);
PWMOutputState(PWM0_BASE, PWM_OUT_5_BIT, true);
uint32_t PWMClock = SysCtlClockGet() / 64;
uint32_t Load = (PWMClock / PWM_FREQUENCY) - 1;
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, Load);
while(1);
//ADC Sampling on PE3
// SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 266);
ADCSequenceDisable(ADC0_BASE, 1);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PWM0*3, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_CH0 | 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, ulADC0Value[100]);
// uint32_t pinVal; // variable to hold the pinRead
pinVal= GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_3);
pinVal1= GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_4);
int a=0;
for ( a=1;a<=1; a++){
uint32_t res=a;
}
/*for (i=0;i<100;i++){
int a=GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_3);
uint32_t adc_val[]=
}*/
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am facing certain problem during debugging. Here, I am generating a signal in a pin of the MCU and then sampling the signal using the ADC.
I get to warnings which seem to have some effect in my code.
#112-D statement is unreachable project.c /ADC_Sampling2 line 66 C/C++ Problem
#169-D argument of type "unsigned long" is incompatible with parameter of type "uint32_t *" project.c /ADC_Sampling2 line 91 C/C++ Problem
#177-D subscript out of range project.c /ADC_Sampling2 line 91 C/C++ Problem
I am not sure why I get those warning. Secondly, during the graphical analysis I am seeing a irrelavantpeak rise, causes unknown. I am attaching the graph image.
