I am trying to do ADC programming in CMSIS RTOS using keil,
Following is my program.. both threads are working but in adc_rx() variable "result" is not modifying, that means a to d conversion is not happening.. what would be the problem??
osThreadDef(led_1,osPriorityNormal,1,0);
osThreadDef(adc_rx,osPriorityAboveNormal,1,0);
int main (void) {
osKernelInitialize (); // initialize CMSIS-RTOS
port_init();
adc_init();
thread_1=osThreadCreate(osThread(led_1),NULL);
thread_adc=osThreadCreate(osThread(adc_rx),NULL);
osKernelStart (); // start thread execution
}
void led_1(void const *arg){
while(1){
GPIOF_AHB->DATA^=0x01;
osDelay(50);
}
}
void led_2(void const *arg){
while(1){
GPIOF_AHB->DATA^=0x010;
osDelay(80);
}
}
void port_init(void){
int i;
SYSCTL->RCGCGPIO|=0x20;
for(i=0;i<20;i++);
GPIOF_AHB->LOCK|=0X4C4F434B;
GPIOF_AHB->AFSEL&=~0x010;
GPIOF_AHB->AMSEL&=~0x010;
GPIOF_AHB->PCTL=0x0;
GPIOF_AHB->DIR|=0x010;
GPIOF_AHB->DEN|=0x010;
}
void adc_rx(void const *arg){
unsigned long result;
while(1){
while((ADC0->SSFSTAT0&0x800)==0){
osDelay(10);
}
result=ADC0->SSFIFO0;
osDelay(10);
}
}
void adc_init(void){
int i;
SYSCTL->RCGCGPIO|=0x10;
for(i=0;i<20;i++);
GPIOE_AHB->AFSEL|=0x0f;
GPIOE_AHB->AMSEL|=0x0f;
GPIOE_AHB->DIR=0x00;
GPIOE_AHB->DEN&=~0x0f;
SYSCTL->RCGCADC|=0x1;
ADC0->SSPRI|=0X3210;
ADC0->ACTSS&=~0x0f;
ADC0->EMUX&=0x00;
ADC0->SSMUX0&=~0XFF;
ADC0->SSEMUX0&=~0XFF; //
ADC0->SSCTL0|=0X06;
ADC0->SSTSH0|=0x0c;
ADC0->ACTSS|=0x01;
}