I'm not totally sure, but if you see into the asm fileboot_vectors.syou can see that it exportsEXPORT ADC_Handler [WEAK]
You can use this function in your driver(?) file by just implementing it there like this: void ADC_Handler(void) { uint16_t conversion = GetWord16(GP_ADC_RESULT_REG); // do required things with the conversion, maybe pass to other function etc... SetWord16 (GP_ADC_CLEAR_INT_REG 0 x0000);/ /我瘦k interrupt should be cleared }
Initialize ADC (maybe inperiph_setup.c?): adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X); // For single ended 3x attentuation, for example SetBits16(GP_ADC_CTRL_REG, GP_ADC_MINT, 1); // Important, or otherwise interrupt will be masked away
Then, perform read with ADC: SetBits16(GP_ADC_CTRL_REG, GP_ADC_START, 1);
I'm not totally sure if something is missing/incomplete. Maybe you should disable adc interrupts while you are executing the handler function.
I want to use the same method. Can you tell me what is GP_ADC_CLK_SEL and how to set it ? I tried the above code and it is not generating any interrupt.
The steps mentioned above are correct, and should trigger an interrupt, make sure that you 've enabled the NVIC for the specified interrupt and also make sure that the interrupts are enabled by the SetBits16(GP_ADC_CTRL_REG, GP_ADC_MINT, 1);, call the enabling of the interrupt just before taking a measurement, this should trigger the interrupt.
You have to explictly start the ADC conversion every time you want to make a measurement, the ADC doesn't free run. If you check the 580 datasheet you will see that the after the conversion is over the GP_ADC_START register flips to 0 and the interrupt bit is set.
Hello Kostakis,
I'm not totally sure, but if you see into the asm fileboot_vectors.syou can see that it exports
EXPORT ADC_Handler [WEAK]void ADC_Handler(void) {
uint16_t conversion = GetWord16(GP_ADC_RESULT_REG);
// do required things with the conversion, maybe pass to other function etc...
SetWord16 (GP_ADC_CLEAR_INT_REG 0 x0000);/ /我瘦k interrupt should be cleared
}
NVIC_SetPriority(ADC_IRQn, 2);
NVIC_EnableIRQ(ADC_IRQn);
adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X); // For single ended 3x attentuation, for example
SetBits16(GP_ADC_CTRL_REG, GP_ADC_MINT, 1); // Important, or otherwise interrupt will be masked away
SetBits16(GP_ADC_CTRL_REG, GP_ADC_START, 1);
I'm not totally sure if something is missing/incomplete. Maybe you should disable adc interrupts while you are executing the handler function.
Thanks!
I want to use the same method.
Can you tell me what is GP_ADC_CLK_SEL and how to set it ?
I tried the above code and it is not generating any interrupt.
Please help me out.
Thanks
Bharath
Hi Bharath,
The steps mentioned above are correct, and should trigger an interrupt, make sure that you 've enabled the NVIC for the specified interrupt and also make sure that the interrupts are enabled by the SetBits16(GP_ADC_CTRL_REG, GP_ADC_MINT, 1);, call the enabling of the interrupt just before taking a measurement, this should trigger the interrupt.
Thanks MT_dialog
It only triggered interrupt once. Why it is not repeating?
How to make it repeat at a particular rate?
Thanks
Bharath
Hi Bharath,
You have to explictly start the ADC conversion every time you want to make a measurement, the ADC doesn't free run. If you check the 580 datasheet you will see that the after the conversion is over the GP_ADC_START register flips to 0 and the interrupt bit is set.
Thanks MT_dialog