I'm starting to wrap my head around the new features of the PIC18F27Q43 - this chip has amazing features for a couple bucks. There's a lot to learn here.
I want to use the NCO to generate a square wave of up to around 5kHz to trigger the DAC to give an adjustable amplitude and frequency square wave. I had the idea that this would be possible using just features of micro, but I'm not seeing how to do this.
I suppose one way to accomplish this is to use an analog switch triggered by the NCO to switch the DAC output.
The goal is an adjustable amplitude and frequency tone to drive a speaker as a replacement for a piezo beeper. I've found that an integrated square wave (low pass filter + gain) yields a pleasant tone.
I am not familiar with that PIC family ... The ones I have been using are the PIC16F15xxx which have NCO and DAC as well as CLC blocks.
The reason I mention CLC blocks (Configurable Logic Cells) is that you may need to use one to bridge the NCO output with the DAC output.
I.e. looking at the datasheet for the PIC18F27Q43 ... (Reference Table 3-1 in datasheet)
1) You would generate the NCO at the desired frequency as an input to the CLC block to serve as a "gate".
2) The DAC1OUT2 (RB7) would serve as an input to the CLC3 or CLC7
3) The Output of the CLC could be directed to an IO pin which in theory would show the NCO frequency at the DAC level.
Another possibility is to tie a resistor 1k or so going from the DAC output to the NCO output and configure the NCO output as an open drain ... See ODCONx.
Your output will be on the NCO output. When the NCO is LOW the output will be low, but when the NCO is HIGH, the DAC level will be present.
The DAC output is an analog voltage, and the CLC is a digital peripheral. There's no connection from the DACOUT to a CLC input.
Another possibility is to tie a resistor 1k or so going from the DAC output to the NCO output and configure the NCO output as an open drain ... See ODCONx.
Your output will be on the NCO output. When the NCO is LOW the output will be low, but when the NCO is HIGH, the DAC level will be present.
So it sounds like two options that won't depend on code are:
● Open drain NCO + DAC
Buffering the DAC with a voltage follower would probably be a good idea.
● NCO toggling an analog switch switching the DAC output. A voltage follower on the DAC output still probably a good idea.
The LM4861 amp chip I'm planning on using has an ENABLE input, so the NCO can probably be left running continuously, and the amp enable used to control the "beep".
I would think the Open drain NCO + DAC combo would give you about the same result as toggling an analog switch... either way you're modulating the DAC output with the NCO signal. You could probably even get rid of the 1K resistor since you'd always have at least 20K on the output of the DAC so you'd never really be shorting the output directly.
Worth a shot.
You probably are going to need a voltage buffer on the DAC output. Shame the Q43 doesn't have any opamps like the Q41/Q71 have, but it's a nice chip otherwise.
The dataSHEET is over 900 pages! There are definitely a few things to learn. If you haven't seen Microchip's HTML datasheets, take a look. They are so much nicer than scrolling up and down through a PDF.
For future this is pretty easy to do on a PSOC (sine or arbitrary waveform) :
Single chip solution.
This was a 4 channel requirement, done on 1 chip, with lots of other resources left
for other tasks.... Amplitude done under software control of WaveDAC.
Easy to do a bursted tone as well, example (again one chip) :
Occasionally I need to generate custom wave forms and burst a known number of cycles into a DUT. This is a single chip solution, board I typically I use is $ 10. You just drag and drop components onto schematic, wire internally with a wire wizard tool and out to pins, right click and config...
So, I just tried this with an 18F27Q43, using PPS to map the NCO1 output into the DAC1 VREF+ and it works for low freq signals just fine. When the NCO freq is around 50KHz or so, things begin to distort and you get a DC offset shift.