Hai
I want to updates the ADC values for every 5 min.
I written the code here
please help me it is not executed where i did wrong in this.
int
main(void)
{
int bb;
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPUEnable();
ROM_FPULazyStackingEnable();
/
/*Uart functions............................................................*/
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
lcd_init();
SysCtlDelay(SysCtlClockGet() / 12);
lcdstr(0x80,(unsigned char *)"Remote Monitoring");
SysCtlDelay(100000);
lcdstr(0x80," ");
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); //For LED
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2); //pin as output
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
// UARTStdioConfig(0, 115200, 16000000);
UARTFIFOEnable(UART0_BASE);
UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);
// ROM_UARTIntDisable(UART0_BASE, UART_INT_TX);
ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
ROM_IntEnable(INT_UART0);
UARTEnable(UART0_BASE);
/**************************ADC configuration***************************************************/
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //for ADC0
// SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); //for ADC1
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_1); //for ADC0
ADCSequenceDisable(ADC0_BASE, 0); //for ADC 0
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 0,0,ADC_CTL_CH0); //channel 0
ADCSequenceStepConfigure(ADC0_BASE, 0,1,ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END); //for ADC0 //channel 1
ADCSequenceEnable(ADC0_BASE, 0);
ADCIntEnable(ADC0_BASE, 0);
IntEnable(INT_ADC0SS0);
ROM_IntMasterEnable();
/*******written for timer functionalities *************************************/
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 800);
ROM_IntEnable(INT_TIMER0A);
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
/**************************************************************************************/
while(1)
{
/*******written for timer functionalities on 5/2/15 *************************************/
TimerControlTrigger(TIMER0_BASE,TIMER_A,1);
// TimerControlTrigger(ADC0_BASE, TIMER_BOTH, 2); //*****************check enable either 2 or 1
// TimerLoadSet(ADC0_BASE, TIMER_BOTH, SysCtlClockGet()); //*****load time into display
/*...........................................................................................*/
/***for timer set flag 6/2/2015**********************/
if(set_flag==1)
{
ADCProcessorTrigger(ADC0_BASE, 0);
}
set_flag=0;
count1=0;
//count5=0;
SysCtlDelay(SysCtlClockGet() / 12);
SysCtlDelay(SysCtlClockGet() / 12);
}
}
void
Timer0_Handler(void)
{
int timer_count=0;
TimerIntClear(TIMER0_BASE,0);
while(timer_count!=801)
{
if(timer_count==800)
{
set_flag=1;
}
timer_count++;
}
timer_count=0;
}
/*************************************************************/
void
ADCHandler(void)
{
int voltage_factor,m;
voltage_factor=(float)4095/660;//factor for voltage, scalling voltage is 2.5 for that count is 3102
//current_factor=(float)2481/20; //for 2v the count is 2481.
current_factor=(float)4095/30;
++count1;
ADCIntClear(ADC0_BASE, 0);
//s=ADCSequenceDataGet(ADC0_BASE, 0, pui32ADC0Value); // // Read ADC Value///. modified on 30-12-2014.
//t12=pui32ADC0Value[0]; //here t is the digital count for voltage.
//t13=pui32ADC0Value[1]; //this t1 is the digital count for current.
/*****30-12-2014 modified******************/
pui32ADC0Value[0]=0;
pui32ADC0Value[0] = HWREG(ADC0_BASE + ADC0_O_SSFIFO0);
pui32ADC0Value[1] = HWREG(ADC0_BASE + ADC0_O_SSFIFO0);
/******************************************/
/***********changes on 2/1/15***************/
t=pui32ADC0Value[0];
t1=pui32ADC0Value[1];
/*****************************************/
vlg_value=t/voltage_factor; //here it will gives the total analog voltage ex: 3722/7.44 = 500v
vlg_value1=t/voltage_factor;
current_value=t1/current_factor;
current_value1=t1/current_factor;
}