Going to play with the DAC on the Z80 PSoC. Dropped the WaveDAC8 symbol on the schematic.
PSoC Pinout
Hooked up to PSoC pin 95.
Added code:
void init_DAC(void)
{
WaveDAC8_Start();
}
Looked at R4 and saw sine wave.
Here's the DAC handler.
uint8 dacState;
uint8 outDataDAC;
uint8 inDataDAC;
///////////////////////////////////////////////////////////////////////////////
// void init_DAC(void) - Initialize the DAC
void init_DAC(void)
{
WaveDAC8_Start();
outDataDAC = 0;
inDataDAC = 0;
}
///////////////////////////////////////////////////////////////////////////////
// void writeDAC(void) - Write to the DAC data
void writeDAC(void)
{
outDataDAC = Z80_Data_Out_Read();
}
///////////////////////////////////////////////////////////////////////////////
// void readDAC(void) - Read the DAC data
void readDAC(void)
{
Z80_Data_In_Write(outDataDAC);
ackIO();
}
///////////////////////////////////////////////////////////////////////////////
// void readStatDAC(void) - Read the DAC Status
void readStatDAC(void)
{
Z80_Data_In_Write(dacState);
ackIO();
}
///////////////////////////////////////////////////////////////////////////////
// void writeCmdDAC(void) - Write the DAC command
// 0 = Turn off DAC output
// 1 = Turn on DAC output
void writeCmdDAC(void)
{
dacState = Z80_Data_Out_Read();
if (dacState == 0)
{
WaveDAC8_Stop();
}
else if (dacState == 1)
{
WaveDAC8_Start();
}
ackIO();
}
Here's the output,
1 KHz. Matches the setup in PSOC Creator.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.