Smart-Pin DAC with Noise
JonTitus
Posts: 193
in Propeller 2
For several hours I have tried and failed (see code below) to get a Smart-Pin to produce what I think it should in the DAC_MODE = DAC Noise setting. Documentation doesn't include an example, and most of the Forum comments haven't helped. I assume I should see random voltages on my scope, but all I see is a short logic-0 pulse on the P20 output when the program starts. I'm revising the SMART PIN section of the v33 documentation, but it's difficult without an assembly-language program I can use as an example, test on my P2 board, and explain. I welcome a working example with comments. It will help others, too. Thanks. --Jon
CON freq = 160_000_000 dat org 0 dirl #20 'Set DAC at Smart-Pin P20 wrpin DACconfig, #20 nop wxpin DACperiod, #20 nop wypin DACvolt, #20 dirh #20 .myloop nop jmp #.myloop DACconfig long %0000_0000_000_10100_00000000_01_00010_0 'Random dither 'DACconfig long %0000_0000_000_10100_00000000_01_00011_0 'PWM dither DACperiod long $0000_0000_0000_0000 ' X15:X0, no period? DACvolt long $0000_0000_0000_FF00 ' Bits Y15:Y0, voltage? How set?
Comments
Here is an (untested) example for 16bit random output: Andy
Here is a little Spin2 code, that outputs a sine wave with a 16bit DAC. It works with Fastspin and with PNUT. Andy
If I'm seeing it right, DDS mode is 8-bit DAC output, whereas the smartpin mode above is 8-bit "real" plus 8-bit dither.
I'd guess that at audio frequencies the smartpin mode would be a lot better...
I agree.