Not applicable
May 17, 2016
11:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 17, 2016
11:14 PM
5 Replies
Attachments are accessible only for community members.
May 18, 2016
12:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 18, 2016
12:08 AM
Not applicable
May 18, 2016
01:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 18, 2016
01:46 AM
Hi Travis,
Thank you very much! It really helps! Now I'm testing the ADC function and wanna design a switch counter using ADC measurement APP(between the ADC high<->low switch), that means,
when I adjust the ADC from (>2048) to (<2048), the variable "count2" would be counted only once, however it seems variable "count2" would be counted continuously till the handler be terminated, this is not what I'm expected, could you please give me some advise? thanks!
Regards,
Fender
Thank you very much! It really helps! Now I'm testing the ADC function and wanna design a switch counter using ADC measurement APP(between the ADC high<->low switch), that means,
when I adjust the ADC from (>2048) to (<2048), the variable "count2" would be counted only once, however it seems variable "count2" would be counted continuously till the handler be terminated, this is not what I'm expected, could you please give me some advise? thanks!
Regards,
Fender
XMC_VADC_RESULT_SIZE_t result;
void Adc_Measurement_Handler()
{
#if(UC_SERIES != XMC11)
result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_Channel_A);
#else
result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_0);
#endif
if(result >= 2048)
{
count1 = 1;
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_2);
}
else
{
DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_2);
if(count1 == 1)
{
//UART_Transmit(&UART_0,alarm_message2, sizeof(alarm_message2)) ;
count1 = 0;
count2 += 1;
}
}
}
int main(void)
{
DAVE_STATUS_t status;
status = DAVE_Init(); /* Initialization of DAVE APPs */
if(status == DAVE_STATUS_FAILURE)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);//ADC test
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
}
}
}
May 18, 2016
07:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 18, 2016
07:06 PM
Hi,
when I adjust the ADC from (>2048) to (<2048), the variable "count2" would be counted only once, however it seems variable "count2" would be counted continuously till the handler be terminated, this is not what I'm expected, could you please give me some advise? thanks!
Well in theory you have an inter locking system in your software such that count1 == 0 will not cause count2 to increment. However do note that there can be noise spikes in your ADC inputs which drives your ADC result to be more than 2048. Hence the reason for your count2 to increase continuously.
when I adjust the ADC from (>2048) to (<2048), the variable "count2" would be counted only once, however it seems variable "count2" would be counted continuously till the handler be terminated, this is not what I'm expected, could you please give me some advise? thanks!
Well in theory you have an inter locking system in your software such that count1 == 0 will not cause count2 to increment. However do note that there can be noise spikes in your ADC inputs which drives your ADC result to be more than 2048. Hence the reason for your count2 to increase continuously.
May 18, 2016
07:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 18, 2016
07:15 PM
To reduce this effect maybe you can place a capacitor as shown.
Not applicable
May 18, 2016
07:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 18, 2016
07:35 PM
Thank you Travis, lesson learned from you:)
Regards,
Fender
Regards,
Fender