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 support@ccsinfo.com

dsPIC33CK32MC102 DACOUT
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
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Mar 28, 2021 12:57 pm     Reply with quote

Thank you T, for your continuing interest and help with this. Your next (favorite beverage/snack) is on me Smile

I compiled and tested your code and not getting expected results, looks like you were trying for a 1KHz signal. Timer1 is ticking nicely at 40KHz, but DACOUT only has a low voltage (40mV) 100MHz signal coming out.

I'll look into your setup to understand what you did. Have to do some "real" work for a while.

Toggled output from Timer1 Interrupt:
[img]http://jgscraft.com/graphics/ds33DACTest1.bmp[/img]

DACOUT pin:
[img]http://jgscraft.com/graphics/ds33DACTest2.bmp[/img]

Cheers,
_________________
Jürgen
www.jgscraft.com
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Mar 28, 2021 1:00 pm     Reply with quote

...perhaps [img] is broken. Here are links to the scope pics:

http://jgscraft.com/graphics/ds33DACTest1.bmp

http://jgscraft.com/graphics/ds33DACTest2.bmp
_________________
Jürgen
www.jgscraft.com
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Mar 29, 2021 12:51 am     Reply with quote

That is right.
At the moment, the output is a 'density' pulse stream. The proportion
of 1's to 0's, gives the average voltage it is to produce.
You need to enable filtering on this to produce the voltage. Too high
level, and it won't change quickly enough. Too low, and you get the
waveform as you are currently seeing.

This is controlled here:
Code:

setup_comparator_dac(COMP_COMMON_DAC_ENABLE | COMP_FILTER_CLK_DIV_1 | COMP_DAC_CLK_DIV_1 | COMP_DAC_CLK_SRC_FVCODIV, 600 1100); //This is the fastest clock settings.


Note the two numbers added at the end. The first specifies the 'TMODTIME'
as a 10 bit value. The second, the SSTIME. The SSTIME should always be
greater than the TMODTIME. The values I've put in, should give you a
good starting point. For faster changes, reduce the first number.

The formulae for these are:
Quote:

TTR = TMODTIME[9:0] * 2/FDAC in Seconds

TSS = SSTIME[9:0] * 2/FDAC in Seconds


Given your signal changes after 1/40000th second, and the clock
is 100MHz, the maximum that can be used is 1250 for SSTIME, while
allowing perhaps half this for a smooth transition, would be sensible.
I've put just slightly lower values to ensure the transition does complete.

This is 'getting your head round' this 'DAC' actually generating a pulse
stream, not a steady voltage.
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Mar 29, 2021 11:09 am     Reply with quote

Thanks, that does produce a nice sine wave at 1KHz. Only 200mV peak to peak though. Even less after some modest filtering. A little weak for my usual amplifier.

Still waiting for my external rail-to-rail DAC, in the mean-time will experiment with the HSPWM module a bit to follow up on the "PWM to DAC" articles I found. There seem to be a few HSPWM posts here I can use for guidance.
_________________
Jürgen
www.jgscraft.com
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Mar 29, 2021 11:31 am     Reply with quote

OK. Try turning down the damping times. See what happens if you halve
them.
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Mar 29, 2021 12:16 pm     Reply with quote

Tried that already, made a little difference. Will experiment further.

On a side note, it looks like this CK series chip I selected is relatively bleeding edge. In looking at the PWM and HSPWM samples and posts, these use EP series and the registers and settings options are different. More study before returning to the workbench.
_________________
Jürgen
www.jgscraft.com
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Mar 30, 2021 12:27 am     Reply with quote

It actually seems to be a very 'odd' hybrid.
It has things that are normally only on the older chips (like the CCP). 99%
of the PIC 24/30/33's, don't have the CCP, instead having the separate
input capture and output compare modules. But then has this slope
compensation DAC, and supports 200MHz operation.
Generally with PIC's. versions are launched because one of the MicroChip
customers 'wants' this particular mix of features. Something over half the
PIC's show this, often having slightly strange mixes of features.
This shows exactly this type of mix....
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Mar 30, 2021 11:06 am     Reply with quote

Yup, I read about the "special" versions in another post and suspected that myself. I also suspect that the CCS setup for this device is a little "off". The HSPWM functions mix setting global and unit registers. I tried various options for the HSPWM functions, without luck and then went for direct register writes, per an example in the reference manual. Worked first time. I may turn this into a musical tone generator yet Very Happy

Hmmm, I have 4 PWM, at least that many timers... can I combine the outputs from multiple PWM via the CLC to essentially combine multiple notes to a single output? Need more time reading and staring at the ceiling. I always wondered what a CLC might be good for, that you couldn't do in software, but this might be an example. Way out of my comfort zone here, but gotta keep those grey cells alive.

Side note: My "afternoon project for a friend" needs a musical tone generator. I thought this would be easy to find but was disappointed. I did find 2 legacy chips, one the size of a Brazilian cockroach (AY38910), and the 16-pin TI SN76489. I tried out the smaller one, but it didn't sound all that great and it needs 5V. And so Idea lets see what the Microchip DSP chips can do, and here I am. Hopefully there'll be a new entry in the code library soon.

Cheers,
_________________
Jürgen
www.jgscraft.com
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Mar 30, 2021 11:30 am     Reply with quote

The biggest problem is actually detail in the documentation.
Any 'non standard' part is rather dependant on the examples, and when
they are new, these don't exist. This was exactly what happened with the
DACOUT, where there were the extra bits needed to actually enable this,
and zero documentation on this. I suspect the same will be true with
the PWM.... Sad
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