I use pic24fj64ga at 32mhz FRC with PLL
and use ADC Base with parameters:
Conv speed: Tcy/2
Asq time: 1
VDD
Created a int timer at 8khz and do only one function ADC.GetByte and it works ok, captures 8000 times in a second.
Howerver when I raise timer to 16khz I see that it actually captures only around 6k bytes.
I did timer slower to 4khz - it captures ok 4000 bytes exactly.
Played with timer frequency more and less and saw that problem occurs after timer frequency at 10-12khz. Less - result is ok, more - result is not correct. Seems like the ADC base gets overloaded.
I tried to increase conv.speed to Tcy and Tcy*x but the whole PIC freezes forever on the step ADC.GetByte. According to datasheet this pic's ADC can get data upto 400khz samples. What may be wrong? Isn't it a bug?
ADC Base freezes the PIC
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ADC Base freezes the PIC
Hello,
What do you have the acquisition time set to and are you sampling more than one ADC? If you are only using one ADC channel then you should be able to greatly reduce the acq time and speed up the overall sample time.
What do you have the acquisition time set to and are you sampling more than one ADC? If you are only using one ADC channel then you should be able to greatly reduce the acq time and speed up the overall sample time.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: ADC Base freezes the PIC
acquisition time is set to 1
I use only one adc and measure signal on one channel.
it reads the channel ok even at acquisition time 50 at 8khz frequency. doesn't stick. but if I try to increase the conversion speed it freezes.
UPD:
I suspect that the problem may be not in ADC itself but in timer. When I have TMR2 disabled, my UART messages got read ok. But once I enable TMR2 (at 8khz it captures ADC and puts to circular buffer) in UART all messages got unreadable.
Here's example
Aren't these problems linked to each other?
I use only one adc and measure signal on one channel.
it reads the channel ok even at acquisition time 50 at 8khz frequency. doesn't stick. but if I try to increase the conversion speed it freezes.
UPD:
I suspect that the problem may be not in ADC itself but in timer. When I have TMR2 disabled, my UART messages got read ok. But once I enable TMR2 (at 8khz it captures ADC and puts to circular buffer) in UART all messages got unreadable.
Here's example
First string is before timer enabled. Second same string after timer enabled.oadc write
ГхтЖБф}sy
Aren't these problems linked to each other?
FC 6.1.3.2 (18.02.2016)
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: ADC Base freezes the PIC
Back to this project and still trying to find what's the problem.
Here's the test project where I could replicate the problem.
Conversion speed Tcy*2 is the maximum which works. Once I change to Tcy*4 and more - it freezes on adc_base:getbyte step.
Any ideas and suggestions?
Here's the test project where I could replicate the problem.
Conversion speed Tcy*2 is the maximum which works. Once I change to Tcy*4 and more - it freezes on adc_base:getbyte step.
Any ideas and suggestions?
- Attachments
-
- adc-test1.fcfx
- (8.17 KiB) Downloaded 243 times
FC 6.1.3.2 (18.02.2016)
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ADC Base freezes the PIC
Hello,
The fastest ADC conversion rate is the Tcy/2 option. The settings after this are allowing the adc conversion to take longer and therefore more precise.
Looking at the code it seems to be allocating the setting correctly to the right register so I wonder if it might be somehow linked to the timer interrupt rate?
The fastest ADC conversion rate is the Tcy/2 option. The settings after this are allowing the adc conversion to take longer and therefore more precise.
Looking at the code it seems to be allocating the setting correctly to the right register so I wonder if it might be somehow linked to the timer interrupt rate?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel