BS2P40 problem with ADC0838
mrsparkle
Posts: 12
Hi,
I have what I think is a simple design using a BS2p40 and an ADC0838, but I keep reading zero for a value? What am I doing wrong? (I know it's gonna be obvious.)
code:
value VAR Byte
cs_pin CON 18 'BS2P13 to ADC0838.18
clk_pin CON 17 'BS2P12 to ADC0838.16
di_pin CON 19 'BS2P14 to ADC0838.17
do_pin CON 14 'BS2P9 to ADC0838.14
HIGH di_pin
DO
LOW cs_pin
SHIFTOUT di_pin, clk_pin, MSBFIRST, [111\5] 'read from ADC0838 channel 7
SHIFTIN do_pin, clk_pin, MSBPOST, [value]
HIGH cs_pin
PAUSE 100
DEBUG ? value
LOOP
schematic: attached
Thanks!
I have what I think is a simple design using a BS2p40 and an ADC0838, but I keep reading zero for a value? What am I doing wrong? (I know it's gonna be obvious.)
code:
value VAR Byte
cs_pin CON 18 'BS2P13 to ADC0838.18
clk_pin CON 17 'BS2P12 to ADC0838.16
di_pin CON 19 'BS2P14 to ADC0838.17
do_pin CON 14 'BS2P9 to ADC0838.14
HIGH di_pin
DO
LOW cs_pin
SHIFTOUT di_pin, clk_pin, MSBFIRST, [111\5] 'read from ADC0838 channel 7
SHIFTIN do_pin, clk_pin, MSBPOST, [value]
HIGH cs_pin
PAUSE 100
DEBUG ? value
LOOP
schematic: attached
Thanks!
Comments
I believe you should be using PIN instead of CON in your pin definitions.
Make sure that you have the PBasic 2.5 directive at the top of your code.
Lemme know how that works out?
Based on your schematic you should have:
ADC0838_CLK PIN 12
ADC0838_CS PIN 13
ADC0838_DI PIN 14
ADC0838_DO PIN 9
O_o...dOH!!! (along with a head-slap)
Yep, you're right, when I used PIN instead of CON it worked fine!
Thanks for your help, I appreciate it!
MrSparkle
MrSparkle - I've marked your OP as "solved".
:thumb:
So you didn't have to change the pin numbers? Pin numbers above 15 should not work.