Shop OBEX P1 Docs P2 Docs Learn Events
BS2P40 problem with ADC0838 — Parallax Forums

BS2P40 problem with ADC0838

mrsparklemrsparkle Posts: 12
edited 2014-02-07 11:43 in BASIC Stamp
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!
sch.doc 36.5K

Comments

  • davejamesdavejames Posts: 4,047
    edited 2014-02-05 17:02
    Hello mrsparkle - welcome to the Forum.

    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?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-02-06 11:52
    Your PIN declarations are incorrect. Dave is correct in that you should use PIN instead of CON for I/O pins, however you also have pins with numbers higher than 15 which isn't possible.

    Based on your schematic you should have:

    ADC0838_CLK PIN 12
    ADC0838_CS PIN 13
    ADC0838_DI PIN 14
    ADC0838_DO PIN 9
  • davejamesdavejames Posts: 4,047
    edited 2014-02-06 12:42
    ...however you also have pins with numbers higher than 15 which isn't possible.


    O_o...dOH!!! (along with a head-slap)
  • mrsparklemrsparkle Posts: 12
    edited 2014-02-07 10:35
    Hi guys,
    Yep, you're right, when I used PIN instead of CON it worked fine!
    Thanks for your help, I appreciate it!
    MrSparkle
  • davejamesdavejames Posts: 4,047
    edited 2014-02-07 11:42
    mrsparkle wrote: »
    Hi guys,
    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:
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-02-07 11:43
    mrsparkle wrote: »
    Hi guys,
    Yep, you're right, when I used PIN instead of CON it worked fine!
    Thanks for your help, I appreciate it!
    MrSparkle

    So you didn't have to change the pin numbers? Pin numbers above 15 should not work.
Sign In or Register to comment.