View previous topic :: View next topic |
Author |
Message |
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
Posted: Sun Aug 13, 2023 6:47 am |
|
|
temtronic wrote: |
2) dump the listing and confirm that the proper register bits are set (enable and output ) |
The VREFCON1 register is set by setup_dac(DAC_OUTPUT | DAC_VSS_VDD) to A0. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Aug 13, 2023 7:28 am |
|
|
Ooh. 5.066.
That could be the problem. I was testing with the current compiler.
I'll have to dig out a version close to this and see if it does generate
reasonable settings. Have a suspicion it may not.
If you look at the compiler change list, 5.072, has the comment:
5.072 Fixed an issue with setup_comparator() and dac_write() function for PIC18F14K22 family.
So the dac_write is not working on your version. Explains what is going on.
Now, this should work instead (since it only writes to the register):
Code: |
#byte DACVAL=0xFBC //being explicit
//dac_write(i); //rem out
DACVAL=i; //replace with
|
Looking at the listing, the dac_write function is talking to the wrong
register. I've explicitly defined the register in case the internal database
is wrong as well.
Looking at the compiler change list is always a good starting point for
problems like this. Understand that the set_analog_pins call is not needed
to make it work, but reduces the power consumption of the chip. The tris
though has to be right. Must be an input (this is the default). If an output,
this will override the analog I/O. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sun Aug 13, 2023 7:34 am |
|
|
It seems a compiler 'bug' in your compiler version is the cause,
Mr. T's reply is why I wanted to SEE the actual listing....
Just because a 'line of code' compiles doesn't mean it actually set the bits up properly. To properly debug you need to see the actual code generated.
Microchip specifically state to use a buffer. While a 'scope 'may' see the signal, it could also introduce a problem( improper loading, capacitance, backfeed, etc. ) |
|
|
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
Posted: Sun Aug 13, 2023 9:07 am |
|
|
I use now another CCS compiler, v. 5040, but RA0 is the same: no signal. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Aug 13, 2023 9:23 am |
|
|
Of course it would. That is even older.
Fixes (99% of the time), are done forwards in time. If there is a
problem fixed in 5.072, then all the compiler before this probably
have the problem. |
|
|
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Aug 14, 2023 12:40 am |
|
|
Why not just put the fix I posted in?.
Use 5.066, and change the output to use this.
The page you point to is for programmer support using CCS programmers.
You are not using a CCS programmer, so has not applicability at all. |
|
|
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
Posted: Mon Aug 14, 2023 7:06 pm |
|
|
Hi all,
I tested under ccs compiler v. 5.115, it works! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Aug 15, 2023 12:50 am |
|
|
Yes. It was fixed in 5.072.
Understand, 5.066, is over six years old. 5.040, seven. You were using
very old faulty compilers.... |
|
|
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
Posted: Tue Aug 15, 2023 2:59 am |
|
|
Ttelmah wrote: | Yes. It was fixed in 5.072.
Understand, 5.066, is over six years old. 5.040, seven. You were using
very old faulty compilers.... |
Thanks Ttelmah,
But I tried to use MPLAB 8.92 with ccs 5.115 and the compilation result does not send anything to RA0.
Do you know under which version of MPLAB ccs 5.115 works well?
I have W11(64Bits). |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Aug 15, 2023 7:11 am |
|
|
when you say you compiled with MPLAB, did you set the 'build configuration' to 'release' ? |
|
|
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
Posted: Tue Aug 15, 2023 9:55 am |
|
|
temtronic wrote: | when you say you compiled with MPLAB, did you set the 'build configuration' to 'release' ? |
You are right: "Release" should have been set. Now the .hex files (generated with Mplab and CCS Compiler) are identical.
Thanks again temtronic. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Aug 15, 2023 12:38 pm |
|
|
years ago...(shh, don't ask...) I'd get caught same way, as MPLAB's default was 'debug'. When I called Microchip, the SW eng was surprised I never used 'debug'. I told him I 'debug' in the real world as that's where the products have to go and no 'simulator' can model the real World. He sent me a 'patch' to MPLAB and furture versions did allow to save 'release' as the default mode.
Being a 'dinosaur' I also don't trust 'wizards' to setup a chip the way I NEED it to be either ..... |
|
|
vas57
Joined: 31 Jan 2022 Posts: 29
|
|
Posted: Tue Aug 15, 2023 7:29 pm |
|
|
temtronic wrote: | years ago...(shh, don't ask...) I'd get caught same way, as MPLAB's default was 'debug'. When I called Microchip, the SW eng was surprised I never used 'debug'... |
That's right, in the real world it's good to rely on yourself the most, but that doesn't always happen, because we live in a real world. |
|
|
|