Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12421 Discussions

How can you measure values from several ADC channels on a DE1 SoC?

TAhme12
Beginner
519 Views

Hi,

 

By following the DE1_SoC_ADC example of the DE1 revF CD, I can collect measurements from a single ADC channel. I have connected a pulse rate sensor to the ADC and am using a timer interrupt on the NIOS II processor to take measurements from the ADC as 2ms interval. However, when I want to measure a different channel, I am unable to receive and data from it?

 

Any help would be appreciated.

 

 

 

int ch[2]; int main(){   printf("Pulse Rate Demo\r\n");   // register the timer irq to be serviced by handle_timer_interrupt() function alt_irq_register(TIMER_IRQ, 0, handle_timer_interrupt); // activate the time IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BASE, ALTERA_AVALON_TIMER_CONTROL_CONT_MSK | ALTERA_AVALON_TIMER_CONTROL_START_MSK | ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);   while(1){ ch[0] = IORD(SW_BASE, 0x00) & 0x07;   ch[1] = IORD(SW_BASE, 0x4) & 0x07;   // set measure number for ADC convert IOWR(ADC_LTC2308_BASE, 0x01, nReadNum);   //printf("%d,%d,%d,%d, %d,%d\n",thresh,T,P,N,adcVal,BPM-1); printf("ch:%d, i:%d, BPM:%d\n",ch[i],i,BPM); usleep(200*1000); } }     void handle_timer_interrupt(void*p, alt_u32 param) { // clear irq status in order to prevent retriggering IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0); // your isr code here   i=!i;     if(i==1){ // start measure IOWR(ADC_LTC2308_BASE, 0x00, (ch[0] << 1) | 0x00); IOWR(ADC_LTC2308_BASE, 0x00, (ch[0] << 1) | 0x01); IOWR(ADC_LTC2308_BASE, 0x00, (ch[0] << 1) | 0x00); i=0; } else { IOWR(ADC_LTC2308_BASE, 0x00, (ch[1] << 1) | 0x00); IOWR(ADC_LTC2308_BASE, 0x00, (ch[1] << 1) | 0x01); IOWR(ADC_LTC2308_BASE, 0x00, (ch[1] << 1) | 0x00); }   // wait measure done while ((IORD(ADC_LTC2308_BASE,0x00) & 0x01) == 0x00);   Value = IORD(ADC_LTC2308_BASE, 0x01);   adcVal = ((float)(Value/1000.0)/5)*1024; .............................................

 

0 Kudos
1 Reply
Rahul_S_Intel1
Employee
154 Views
May I have the project file for reference
Reply