MOD54415 DAC Analog Output
Posted: Fri Sep 07, 2012 10:39 am
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
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);
}
}