ZHCSRN7A January 2023 – September 2023 DAC539G2-Q1
PRODUCTION DATA
Calculate the PWM frequency by using the time steps and code step from Table 7-27, either Equation 4 for a triangle wave or Equation 5 for a sawtooth wave, and the selected FUNCTION-MAX and FUNCTION-MIN DAC codes. Section 7.4.2.1 describes the details on the function generation settings. The FUNCTION-MAX and FUNCTION-MIN DAC codes represent the peaks of the triangle or sawtooth waveforms. To achieve a frequency of 100 Hz, this example uses a triangle wave with a margin high of 725, a margin low of 100, slew rate of 8 μs, and code step of 1 LSB:
The DAC539G2-Q1 is a 10-bit device, which means the maximum DAC code is 1023d. Choose margin-high and -low values that are away from the endpoints to avoid effects from the zero-code and full-scale errors.
For small step sizes, the duty cycles can be estimated by:
Where VOUT_DATA_X is the DAC code set in the LUT for every combination of the GPI inputs (VOUT-DATA-X).
For a duty cycle duty cycle of 12.5%, the VOUT_DATA_X is calculated by:
This result is rounded up to 647d (0x287). Table 8-2 lists the LUT table values for the remaining duty cycles.
DUTY CYCLE | VOUT_DATA_X |
---|---|
12.5% | 0x287 |
25% | 0x239 |
37.5% | 0x1EB |
50% | 0x19D |
62.5% | 0x14E |
75% | 0x100 |
87.5% | 0x0B2 |
100% | 0x064 |
The LUT codes are written to the DAC outputs depending on the state of the three GPI pins. The DAC codes do not have to increase chronologically with the GPIs. A programmable delay can be used so that the DAC output changes only after the GPIs have settled to avoid any switching noise on the output. The delay setting is 16 bits with a step size of 160 μs, and is stored in the GPI-DEBOUNCE SRAM register. Set the delay code to 312d for a 50-ms delay.
The oscillator error is directly reflected on the output frequency of the PWM signal. This error can be compensated for by adjusting the margin-high and -low codes to adjust the frequency of the triangle wave generated on channel 0. The DAC539G2-Q1 oscillator error is stored in SRAM register 0x9E. This error is a 6-bit value with a code step of 0.2%, so the margin-high and -low codes can be modified to correct for –6.4% to +6.2% of error. For example, for code 0x2C, the oscillator error is –4%, or the frequency is 4% higher than the target. Increase the margin high – margin low differential value so that the calculated frequency is 4% lower than the target value.
Follow these guidelines to set up the registers on the DAC539G2-Q1:
REGISTER FIELD NAME | ADDRESS [FIELD] | ADDRESS LOCATION |
---|---|---|
FUNCTION-CONFIG | 0x20[10:9][6:0] | SRAM |
FUNCTION-MAX | 0x21[15:6] | SRAM |
FUNCTION-MIN | 0x22[15:6] | SRAM |
GPI-DEBOUNCE | 0x23[15:0] | SRAM |
VOUT-DATA-0 | 0x24[15:6] | SRAM |
VOUT-DATA-1 | 0x25[15:6] | SRAM |
VOUT-DATA-2 | 0x26[15:6] | SRAM |
VOUT-DATA-3 | 0x27[15:6] | SRAM |
VOUT-DATA-4 | 0x28[15:6] | SRAM |
VOUT-DATA-5 | 0x29[15:6] | SRAM |
VOUT-DATA-6 | 0x2A[15:6] | SRAM |
VOUT-DATA-7 | 0x2B[15:6] | SRAM |
DAC-0-VOUT-CMP-CONFIG | 0x15[12:10][4:0] | Register |
DAC-1-VOUT-CMP-CONFIG | 0x03[12:10][4:0] | Register |
COMMON-CONFIG | 0x1F[15:0] | Register |
DEVICE-MODE-CONFIG | 0x25[15:0] | Register |
STATE-MACHINE-CONFIG | 0x27[2:0] | Register |
The pseudocode for this application example is as follows:
//SYNTAX: WRITE <REGISTER NAME(Hex Code)>, <MSB DATA>, <LSB DATA>
//Stop the state machine
WRITE STATE-MACHINE-CONFIG(0x27), 0x00, 0x03
//Stop the function generator
WRITE COMMON-DAC-TRIG(0x21), 0x00, 0x00
//Set the code step, slew rate, and waveform mode
WRITE FUNCTION-CONFIG(SRAM 0x20), 0x00, 0x02
WRITE FUNCTION-MAX(SRAM 0x21), 0xB5, 0x40
WRITE FUNCTION-MIN(SRAM 0x22), 0x19, 0x00
//Set the programmable debounce delay (this is the device default)
WRITE GPI-DEBOUNCE(SRAM 0x23), 0x01, 0x38
//Set the LUT values
WRITE VOUT-DATA-0(SRAM 0x24), 0xA1, 0xC0
WRITE VOUT-DATA-1(SRAM 0x25), 0x8E, 0x40
WRITE VOUT-DATA-2(SRAM 0x26), 0x7A, 0xC0
WRITE VOUT-DATA-3(SRAM 0x27), 0x67, 0x40
WRITE VOUT-DATA-4(SRAM 0x28), 0x53, 0x80
WRITE VOUT-DATA-5(SRAM 0x29), 0x40, 0x00
WRITE VOUT-DATA-6(SRAM 0x2A), 0x2C, 0x80
WRITE VOUT-DATA-7(SRAM 0x2B), 0x18, 0xC0
//Set the channel 0 reference to VDD (this is the device default)
WRITE DAC-0-VOUT-CMP-CONFIG(0x15), 0x04, 0x00
//Set channel 1 reference to VDD (this is the device default)
WRITE DAC-1-VOUT-CMP-CONFIG(0x03), 0x04, 0x00
//Power on the DAC channels (this is the device default)
WRITE COMMON-CONFIG(0x1F), 0x03, 0xF9
//Set the device mode (this is the device default)
WRITE DEVICE-MODE-CONFIG(0x25), 0x80, 0x40
//Start the state machine
WRITE STATE-MACHINE-CONFIG(0x27), 0x00, 0x03
//Save settings to NVM
WRITE COMMON-TRIGGER(0x20), 0x00, 0x02