Hi there.
My problem here is that I am using the codewarrior device initialization bean to set up the ADC. I have not yet experienced any problems when using the 'Device Initialization' tool when using it to setup pins for GPIO. I have included below the exact bean parameters, and the code to write a '1' to the START0 bit of register CNTRL1. Can anyone advise on why a scan will not run?
-Setting
Clock Settings
Clock Divisor select divide by 8
ADC Freq 5MHz
Stop mode 0 no
Stop mode 1 no
ADC mode Once sequential
Parrallel mode Independent
Trigger mode 0 Write to START bit only
Trigger mode 1 " "
High voltage ref source External (AN2 connected to VDDA)
Low voltage ref source External (AN6 connected to GND)
-A/D channels
AN0-AN1 Single ended mode
AN2-AN3 " "
AN4-AN5 " "
AN6-AN7 " "
-sample 0
channel AN0
sample Enabled
zero crossing Disabled
low limit 0
high limit 32752 (highest value before disabling high limit)
-sample 1- 7 All disabled
-pins
-AN0 Enabled
-AN2/Vrefh pin Enabled
-AN6/Vrefl pin Enabled
the rest of the pins are disabled
Sync0 and sync1 are both disabled
-interrupts
-conversion complete
interrupt INT_ADC_ADCA
request Enabled
level 7
Priority Highest
End of scan interrupt Enabled
conversion complete interrupt for scanner b is disabled
Zero crossing or limit error
interrupt INT_ADC_ADCINT
Request Enabled
Level 7
Priority 6
Zero crossing Disabled
Low limit error Disabled
High limit error Enabled
-Initialization
Start ADC conversion after Init A no
" " B no
Power down ADC0 no
" " 1 no
Power down voltage ref no
Auto power down disabled
power up delay 13
Auto stand by disabled
The following code is used to start the scan.
#include "support_common.h"
uint16 Set_START0 = 0;
set_START0 = CNTRL1;
Set_START0 = (uint16)(Set_START0 | CTRL1_START0_BITMASK);
CTRL1 = SetSTART0;
The code compiles, but as far as i can tell, there is no scan being run, and at no point during debug will the program jump to the corresponding end of scan ISR.
Apologies if I have gone a bit over kill on the information included here, I just didn't want to miss out anything that might be important. If anyone has any suggestions, I would be most greatfull. Thanks in advance. Antony
已解决! 转到解答。
Hello,
I think that the problem is in the ADC´s ISR where there is a neverending loop that causes your program hanging in the isr - see below.
for(;
{
++count;//this is where i expect my program to end up
}
Corrected project is enclosed.
best regards
Vojtech Filip
Processor Expert Support Team
Hi Processor expert, I have attached a simple project, although this is not a version of the program i have actually been working on, i knocked this one up quickly to demonstarte how my actual program initializes the ADC scan, and how i want it to use the end of scan interrupt. I do experience the same problem with this program as i do my actual program. All timers and clocks have been set the same.
Hello,
I have reproduced the problem.It’s not a problem in generated code but there is missing clearing sequence in handling of PIT interrupt . There is also set the priority of ADC interrupt to lower value than PIT. Due to missing the clearing sequence PIT hangs in handling of the isr – and it cannot be interrupted by ADC because the interrupt has lower priority and it never occurs.
I have corrected your project, please find it enclosed.
best regards
Vojtech Filip
Processor Expert Support Team
Thank you for your response ProcessorExpert. I loaded the program you returned. I am still experiencing problems with the handling of interrupts. I cleared the PIF bit where you stated to do so, I then found that my program did generate an interrupt from the ADC, but then the program continued to jump immediately back to the ADC end of scan interrupt. I assumed that this must be due to a similar reason as before, so i cleared the EOSIE0 (interrupt enable) bit at the beginning of the interrupt, and set it again before writing to START0. This did seem to stop the re-calling of the ADC end of scan interrupt, however, since clearing the PIF bit, no further PIT0 timeout interrupts are occuring. I have tried setting the OVW bit, i thought this might jog the PIT back into action, but still there appears to be no activity. Can you advise? Thanks again. Antony
Hello,
I think that the problem is in the ADC´s ISR where there is a neverending loop that causes your program hanging in the isr - see below.
for(;
{
++count;//this is where i expect my program to end up
}
Corrected project is enclosed.
best regards
Vojtech Filip
Processor Expert Support Team