BS2 - inconsistent program run
I have one of those AD9851 DDS modules that you find on ebay hooked up to a BS2, on a Board of Education. When I first power on the Board of Education, the DDS module is programmed and I get the correct output. If I switch power off briefly, then back on, the DDS module is not getting programmed correctly and I get no output. If I hit the reset button on the Board of Education, the DDS works every time. It only seems to be a problem after the first power up. This makes no sense to me.
The code is posted below. I have already tried inserting pauses throughout the program to no avail.
The code is posted below. I have already tried inserting pauses throughout the program to no avail.
' {$STAMP BS2}
' {$PBASIC 2.5}
D7 PIN 3 ' D7 is used as input in 40-bit serial mode.
W_CLK PIN 2 ' Word Load Clock. Clocks each bit into D7 on rising edge.
FQ_UD PIN 1 ' Frequency Update. Transfers 40-bit word from input buffer into
' DDS on rising edge. Don't toggle unless valid data is loaded.
RESET PIN 0 ' Reset. Active high.
Setup: ' Set needed pins to output and low.
LOW D7
LOW W_CLK
LOW FQ_UD
LOW RESET
Main:
PULSOUT RESET, 10 ' Pulse Reset for 20 us.
PULSOUT W_CLK, 10 ' Set serial load enable mode.
PULSOUT FQ_UD, 10 ' This works when the serial mode is hardwired.
SHIFTOUT D7,W_CLK,LSBFIRST,[$00,$00,$00,$00,$00] ' Clear DDS input register with zeros.
PULSOUT FQ_UD, 10 ' Pulse FQ_UD high for 20 us to transfer register to DDS.
SHIFTOUT D7,W_CLK,LSBFIRST,[$79,$56,$34,$12,$01] ' 12.8 MHz output with 30 MHz x 6 ref clock.
PULSOUT FQ_UD, 10 ' Pulse FQ_UD high for 20 us to transfer register to DDS.
END
Comments