CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

18f14k22 DAC
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vas57



Joined: 31 Jan 2022
Posts: 29

View user's profile Send private message

PostPosted: Sun Aug 13, 2023 6:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 13, 2023 7:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 13, 2023 7:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 13, 2023 9:07 am     Reply with quote

I use now another CCS compiler, v. 5040, but RA0 is the same: no signal.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sun Aug 13, 2023 9:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 13, 2023 10:20 pm     Reply with quote

I have now seen https://www.ccsinfo.com/devices.php?page=versioninfo.
I will try with a compiler from Microchip.
Thanks everyone for all the advice. I think the post can be closed.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Aug 14, 2023 12:40 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 14, 2023 7:06 pm     Reply with quote

Hi all,

I tested under ccs compiler v. 5.115, it works!
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Aug 15, 2023 12:50 am     Reply with quote

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.... Sad
vas57



Joined: 31 Jan 2022
Posts: 29

View user's profile Send private message

PostPosted: Tue Aug 15, 2023 2:59 am     Reply with quote

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.... Sad

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

View user's profile Send private message

PostPosted: Tue Aug 15, 2023 7:11 am     Reply with quote

when you say you compiled with MPLAB, did you set the 'build configuration' to 'release' ?
vas57



Joined: 31 Jan 2022
Posts: 29

View user's profile Send private message

PostPosted: Tue Aug 15, 2023 9:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 15, 2023 12:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 15, 2023 7:29 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group