Problem with the PIC16F648 ADC
Moderator: Benj
Problem with the PIC16F648 ADC
The high-case ADC "ADRESH"is not read.
Previously, everything worked and now it doesn't .
When using macros (Flowcode) everything works but the program
remains in interrupts while the ADC is running and this is 100-200 uS
lose time . You can return for the result in interrupts.
Please make an ADC interrupt macro!!!
Sincerely, Osta.
File attached
Previously, everything worked and now it doesn't .
When using macros (Flowcode) everything works but the program
remains in interrupts while the ADC is running and this is 100-200 uS
lose time . You can return for the result in interrupts.
Please make an ADC interrupt macro!!!
Sincerely, Osta.
File attached
- Attachments
-
- IMG
- ADC.jpg (58.57 KiB) Viewed 7230 times
-
- ADC.fcfx
- prog
- (26.18 KiB) Downloaded 194 times
- 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: Problem with the PIC16F648 ADC
Hello,
I thinkt he problem was your interrupt enable code. You were using bit names such as GO = 1 whereas this should have been ADCON0bits.GO = 1
I've made some changes to your program inside the interrupt enable icon, hopefully it will improve things for you.
Also I've noticed your if statement had been converted to C with customised code to add a { after the decision. This should not be required but i've left as is as it doesn't seem to be causing issues in the generated code.
I thinkt he problem was your interrupt enable code. You were using bit names such as GO = 1 whereas this should have been ADCON0bits.GO = 1
I've made some changes to your program inside the interrupt enable icon, hopefully it will improve things for you.
Also I've noticed your if statement had been converted to C with customised code to add a { after the decision. This should not be required but i've left as is as it doesn't seem to be causing issues in the generated code.
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
Re: Problem with the PIC16F648 ADC
Hi Benj!
It doesn't change anything...
My version of the program works
only if I read lowercase,
I attached a photo below.
Sincerely Osta
It doesn't change anything...
My version of the program works
only if I read lowercase,
I attached a photo below.
Sincerely Osta
- Attachments
-
- Oscil
- ADC.jpg (248.2 KiB) Viewed 7213 times
-
- ADRESL
- ADRESL.jpg (62.62 KiB) Viewed 7213 times
Re: Problem with the PIC16F648 ADC
Hi Benj!
I apologize for making a typo.
I use the PIC16F684 controller
I apologize for making a typo.
I use the PIC16F684 controller
Re: Problem with the PIC16F648 ADC
Hi Benj!
Your recommendation doesn't work!
As before, the senior level is not readable.
Only the lower-level ADC is read.
Above is a picture of the lowercase operation
What to do?
Your recommendation doesn't work!
As before, the senior level is not readable.
Only the lower-level ADC is read.
Above is a picture of the lowercase operation
What to do?
- 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: Problem with the PIC16F648 ADC
Hi Osta,
You have set the ADC to be Right justified which means that the majority of the ADC result will reside in the ADRESL register (ADFM = 1).
Maybe this should instead be (ADFM = 0).
You have set the ADC to be Right justified which means that the majority of the ADC result will reside in the ADRESL register (ADFM = 1).
Code: Select all
ADCON0 = 137; // Настройка АЦПа
Code: Select all
ADCON0 = 9; // Настройка АЦПа
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
Re: Problem with the PIC16F648 ADC
Рш Benj
That's right, I need to move to the right.
otherwise, I will have to do an extra operation-shift the entire result by 6 bits
When the ADC is shifted to the right, it is 768
the first two bits must be used in upper case.
That's right, I need to move to the right.
otherwise, I will have to do an extra operation-shift the entire result by 6 bits
When the ADC is shifted to the right, it is 768
the first two bits must be used in upper case.
- Attachments
-
- ADRESH
- ADRESH.jpg (62.04 KiB) Viewed 7174 times
Re: Problem with the PIC16F648 ADC
The macro does this.
And I need to start the ADC and get out of interrupts as soon as possible.
Go back for the result, change the channel and exit again. This is a cycle that takes less time
, measurements run in parallel and there is no reason to wait for the result in interrupts.
And I need to start the ADC and get out of interrupts as soon as possible.
Go back for the result, change the channel and exit again. This is a cycle that takes less time
, measurements run in parallel and there is no reason to wait for the result in interrupts.
- Attachments
-
- Code snippet
- Безымянный.jpg (87.9 KiB) Viewed 7170 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Problem with the PIC16F648 ADC
Maybe try taking out the code that swaps ADC channel on every sample.
Just try sampling one channel to begin with and see if that works.
Just try sampling one channel to begin with and see if that works.
Re: Problem with the PIC16F648 ADC
Hi LeighM
The macro works fine!
I can't count the upper case
when shifting to the right .
The macro works fine!
I can't count the upper case
when shifting to the right .
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Problem with the PIC16F648 ADC
I just wondered if you were getting low value readings due to too short A/D acquisition time
Re: Problem with the PIC16F648 ADC
Hi LeighM
I did all three options the result is the same.
I did all three options the result is the same.
- Attachments
-
- ADCON1
- ADCON1.jpg (86.03 KiB) Viewed 7136 times
Re: Problem with the PIC16F648 ADC
This is the same solution implemented in Flowcode 6
and it works.
I did the same in Flowcode 7.
and it works.
I did the same in Flowcode 7.
- Attachments
-
- FC6
- FC6.jpg (53.64 KiB) Viewed 7133 times
Re: Problem with the PIC16F648 ADC
Hi LeighM
I still have the old FC6 file and the new FC8 file
in FC7 it is lost but I installed FC7 yesterday and tried IT
it doesn't work either.
I still have the old FC6 file and the new FC8 file
in FC7 it is lost but I installed FC7 yesterday and tried IT
it doesn't work either.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Problem with the PIC16F648 ADC
OK,
I've just noticed that ADRESH and ADRESL are in different memory banks, I wonder if this is a silicon/compiler issue
I've just noticed that ADRESH and ADRESL are in different memory banks, I wonder if this is a silicon/compiler issue
Re: Problem with the PIC16F648 ADC
That may be so.
Well, if you can take that into account.
I can't change the controller
this is an old project, and I can
rely only on the software solution
and this version of the program.
Thanks for the help.
With respect Osta.
Well, if you can take that into account.
I can't change the controller
this is an old project, and I can
rely only on the software solution
and this version of the program.
Thanks for the help.
With respect Osta.