Shop OBEX P1 Docs P2 Docs Learn Events
Looking for Simple DAC and ADC Spin2 Examples — Parallax Forums

Looking for Simple DAC and ADC Spin2 Examples

I really enjoyed reading JonnyMac's Nuts&Volts article. It really helped me understand the PWM mode of the Smartpins. Are there similar examples on how to use the Propeller 2's Smartpins in DAC and ADC modes?

I've been trying to catch up on all the relevant P2 threads hoping to make sense of DAC and ADC modes but I'm going to cry "Uncle" and ask for help.

I don't need fast response times for either the DAC or the ADC. I'm hoping for an example similar to Jon's PWM code:
pub start(pin, duty, hz) | x

‘’ Configure smart pin for DMX-compatible PWM
‘’ --  pin - output pin (0..55)
‘’ -- duty - duty cycle of output 0 to 255 (100%)
‘’ --   hz - pwm output frequency

  if (hz > 0)
    pp := pin
    x.word[1] := 255
    x.word[0] := 1 #> ((clkfreq / 255) / hz) <# $FFFF
    pinstart(pin, P_OE | P_PWM_SAWTOOTH, x, duty)

Ideally an example I can use with the Propeller Tool.

Comments

Sign In or Register to comment.