Hi, all.
We are trying to use ADC with free run mode but failed to trigger interrupt continuously after tried with different values of ADCTL. This is what we had done with the dm365 board:
Hardware:
the dm36x evm (rev d) board (demo).
Software initialization before register the interrupt(s):
1. Write ADC_ADCTL with BIT_SCNMD | BIT_CMPMD | BIT_CMPIEN
BIT_SCNMD /* scan mode: Free Run */
BIT_CMPMD /* interrupt is generated when CMPLDAT <= ADC input data <= CMPUDAT */
BIT_CMPIEN /* comparator interrupt enable bit */
2. Write comparator data with 0x07 cus it is read form the ch0
ADC_CMPLDAT = 0x07
ADC_CMPHDAT = 0x07
ADC_CMPTGT = 0x3F
3. Write SETDIV to Setup Divide Value for Start A/D
ADC_SETDIV = 0
4. Write CHSEL to select all channels
ADC_CHSEL = 0x3F
5. Write EMUCTRL: Ignore Suspend and operates normally */
ADC_EMUCTRL = 1
6. Setup Irq…
7. Write INTC_EINT1 with 1<<(59-32) to enable interrupt number 59
INTC_EINT1 = read(INTC_EINT1) | 1<<(59-32)
8. Write interrupt Mux
INT_MUX = read(INT_MUX) | 1<< (21)
9. Write Start=1
ADC_ADCTL = read(ADC_ADCTL) | ADCTL_BIT_START
10. Wait until BIT_BUSY to change to 1
while(!(read(ADC_ADCTL) & ADCTL_BIT_BUSY))
11. Wait until BIT_BUSY to change to 0
while(read(ADC_ADCTL) & ADCTL_BIT_BUSY)
l Write ADC_ADCTL to clear the flag of CMPFLG in the interrupt handle:
ADC_ADCTL = read(ADC_ADCTL) & ADCTL_BIT_START
12. Then I read this before / after the interrupt been handled:
ADC_ADCTL = 0xb3 ADC_ADCTL = 0xfb
ADC_CMPTGT = 0x3f ADC_CMPTGT = 0x3f
ADC_CMPLDAT = 0x7 ADC_CMPLDAT = 0x7
ADC_CMPHDAT = 0x7 ADC_CMPHDAT = 0x7
ADC_SETDIV = 0x0 ADC_SETDIV = 0x0
ADC_CHSEL = 0x3f ADC_CHSEL = 0x3f
ADC_AD0DAT = 0x7 ADC_AD0DAT = 0x7
ADC_AD1DAT = 0x380 DC_AD1DAT = 0x380
ADC_AD2DAT = 0x205 ADC_AD2DAT = 0x206
ADC_AD3DAT = 0x171 ADC_AD3DAT = 0x171
ADC_AD4DAT = 0x9 DC_AD4DAT = 0xb
ADC_AD5DAT = 0x4 ADC_AD5DAT = 0x4
ADC_EMUCTRL = 0x1 ADC_EMUCTRL = 0x1
The first row was been reading when the interrupt was triggering and the second row was reading when the interrupt has stopped.
Some time it is terminated when:
A. Check the numbers of interrupts before enable the interrupt:
cat /proc/interrupts
59: 3648249 AINTC ADC
B. Check the numbers of interrupts after the interrupt has stopped:
cat /proc/interrupts | grep ADC
59: 5506816 AINTC ADC
cat /proc/interrupts | grep ADC
59: 5506816 AINTC ADC
59: 3648249 AINTC ADC
It means that the interrupt number 59 has been triggered 231378 timers to AINTC.
Sometimes it stops after 10 seconds when the interrupt is enabled; sometimes it is less than 10 seconds.
We have not pressed any button or changed anything when the applications is running.
It is strange that the interrupt stops with no changes on the board. We had tried with SCNIEN, but they are the same.
It is also strange that the 0xfb is read form ADCTL because if SCNIEN is disabled, how does SCNFLG comes out?
Any ideas?
Thinks in advance.
Mike.