Hello,
i am trying to create sine wave using TMDXDOCK280049M,
my code is working after that i flash it, but if i plug out the bored the program are deleting it self.
the board is never use before.
- I tried to play with the boot switch (S1) and check all of the state of it. GPIO24 and GPIO32 are stays low.
- I tried to call InitGpio() function,but it still dont work,GPIO24 and GPIO32 are staying low.
here is my code:
#include "F28x_Project.h"
//
// Globals
//
volatile struct DAC_REGS* DAC_PTR[3] = {0x0,&DacaRegs,&DacbRegs};
//uint16_t dacval = 2048;
//
// Defines
//
#define REFERENCE_VDAC 0
#define REFERENCE_VREF 1
#define DACA 1
#define DACB 2
#define REFERENCE REFERENCE_VDAC
#define DAC_NUM DACA
//
// Function Prototypes
//
void configureDAC(uint16_t dac_num);
#define PERIOD 120
static const uint16_t D_Val[PERIOD] = { 0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794
};
//
// Main
//
void main(void)
{
InitGpio(); // new adding
//
// Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
//
InitSysCtrl();
//
// Disable CPU interrupts
//
DINT;
//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags are cleared.
//
InitPieCtrl();
//
// Clear all interrupts and initialize PIE vector table:
//
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
//
// Configure DAC
//
configureDAC(DAC_NUM);
int i=0;
while(1)
{
while(i<PERIOD)
{
DAC_PTR[DAC_NUM]->DACVALS.all = D_Val[i];
DELAY_US(166.35); //control on the frequency 166.35 = 50.0062hz
i++;
}
i=0;
}
}
//
// configureDAC - Configure specified DAC output
//
void configureDAC(uint16_t dac_num)
{
EALLOW;
DAC_PTR[dac_num]->DACCTL.bit.DACREFSEL = REFERENCE;
DAC_PTR[dac_num]->DACOUTEN.bit.DACOUTEN = 1;
DAC_PTR[dac_num]->DACVALS.all = 0;
DELAY_US(10); // Delay for buffered DAC to power up
EDIS;
}
//
// End of File
thank you very much
Michael