MOD54415 DAC Analog Output

Discussion to talk about hardware related topics only.
Post Reply
aseger
Posts: 4
Joined: Fri Sep 07, 2012 10:30 am

MOD54415 DAC Analog Output

Post by aseger »

I just recently received a MOD54415 and the the demo board for it. I have been playing around with it for a few days and would now like to try generating an analog voltage using the onboard DAC. Does anybody have any experience with this? Here is the code that I have written so far, which is meant to implement the automatic generation mode on the mcf54415. I can tell that the data register seems to be incrementing properly, but I don't see an output on J2 pin 9. It has been about 10 years since I have worked with a microcontroller, or even programmed in C++ for that matter, so any suggestions are most welcome.

Thanks,
Adam

Code: Select all

#include "predef.h"
#include <stdio.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <dhcpclient.h>
#include <smarttrap.h>
#include <taskmon.h>
#include <NetworkDebug.h>
#include <sim.h>
#include <iostream>
#include <basictypes.h>


extern "C" {
void UserMain(void * pd);
}

const char * AppName="SPI_DAC";

void UserMain(void * pd) {
    InitializeStack();
    if (EthernetIP == 0) GetDHCPAddress();
    OSChangePrio(MAIN_PRIO);
    EnableAutoUpdate();
    StartHTTP();
    EnableTaskMonitor();

    #ifndef _DEBUG
    EnableSmartTraps();
    #endif

    #ifdef _DEBUG
    InitializeNetworkGDB_and_Wait();
    #endif

    volatile WORD Buff_Data;

    iprintf("Application started\n");
    //Set up initial settings for DAC, including timing parameters//
    sim1.mcpwm.sm[0].cr1=0x70;
    sim1.mcpwm.mcr=0xFF;
    sim1.ccm.dactsr=0x0;
    sim2.adc.cal=0x1;
    sim2.dac[0].data=0x745;
    sim2.dac[0].step=0x0;
    sim2.dac[0].max=0xE8A;
    sim2.dac[0].min=0x745;

    //Start DAC Conversion//
    sim2.dac[0].cr=0x38;
    iprintf("DAC Running\n");
    while(1){
    	Buff_Data=sim2.dac[0].data;
    	iprintf("Data: %x, Prescaler: %x\n", sim2.dac[0].data, sim1.mcpwm.sm[0].cr1);
    }
}
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: MOD54415 DAC Analog Output

Post by pbreed »

Have you connectd the A/D and Dac refrerence voltageS?
The MOD-DEV-70 does nto connect them by default.
The next version of the Moddev 70 will have reference umpers, but the current version does not.

PAul
aseger
Posts: 4
Joined: Fri Sep 07, 2012 10:30 am

Re: MOD54415 DAC Analog Output

Post by aseger »

I did connect the reference voltages to a power supply (used about 2.2V). I still did not see anything on the output though.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: MOD54415 DAC Analog Output

Post by pbreed »

I'm traveling for the rest of this week so I will likely not get to it...
but I'd look in the A/D section to see if there is some setting that switches the pin from A/D to DAC mode.
I'd also look in the pin assignment registers in the gpio section for the same type of setting....
I'll try to get to this today... alas odds are low.

Paul
aseger
Posts: 4
Joined: Fri Sep 07, 2012 10:30 am

Re: MOD54415 DAC Analog Output

Post by aseger »

Thanks for the input. I have already set the pins from ADC to DAC using

Code: Select all

sim2.adc.cal=0x1;
,but I will check the GPIO section as well to see if I missed something.

Thanks
aseger
Posts: 4
Joined: Fri Sep 07, 2012 10:30 am

Re: MOD54415 DAC Analog Output

Post by aseger »

I found one final register which needed to be set:

Code: Select all

sim1.ccm.misccr2=0xA8A3;
Now the onboard DAC seems to work relatively well, but I will probably implement the glitch filter next.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: MOD54415 DAC Analog Output

Post by pbreed »

Good job hunting down all the bits and getting it to work...

If you can package up your working example and submit it to support will give you a one year support extension....

Paul
ddeham
Posts: 9
Joined: Tue Feb 24, 2009 7:37 am

Re: MOD54415 DAC Analog Output

Post by ddeham »

Has anyone figured out how to use the DAC to output a waveform? On page 30-12 of the Freescale Manual it says:

"program a timer module to pulse SYNC_IN"
[...]
"4. Set DACn_CR[DACOUT] and clear DACn_CR[UP, PDN]."

How do I set the timer to toggle SYNC_IN?
How do I set DACn_CR[DACOUT]? I don't see any reference to the DACOUT bit in the DAC Control Register.

Dan
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: MOD54415 DAC Analog Output

Post by rnixon »

Maybe the dacout isn't used any more and its one of the reserved bits. What happens when you run your program the way it is, with sync_in enabled?
Post Reply