Shop OBEX P1 Docs P2 Docs Learn Events
Shiftout (SPI) and I2C issues — Parallax Forums

Shiftout (SPI) and I2C issues

Rex HeyerRex Heyer Posts: 1
edited 2010-06-01 16:42 in General Discussion
Thanks in advance for any help.

I am simply trying to get any serial communication going (not counting the standard asynchronous method) . I am using SX/B for the compiler and have tried generating basic SPI and I2C output. The weird thing is that I have attached the outputs to an oscilloscope and the chips only output occasional voltage spikes...no data. Please review the very basic software routines and let me know if I am missing anything.

R>

Comments

  • ZootZoot Posts: 2,227
    edited 2010-05-31 14:58
    Looks like they should work. I would move the bulk of the program to a "Main" label so that start isn't always used, e.g.

    
    Start:
      TRIS_LEDs = %00000000
    
    
    Main:
    
      DO
        FOR i = 0 to 255
            SHIFTOUT Dpin, Cpin, LSBFIRST, i
                LEDs = i    
            PAUSE 1000                     
        NEXT
      LOOP
    
    



    But that shouldn't matter too much in this case. I would expect to see data on your 'scope....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2010-06-01 16:42
    Your missing the Latch signal which occurs after the SHIFTOUT.

    ' -------------------------------------------------------------------------
    ' Device Settings
    ' -------------------------------------------------------------------------
    DEVICE   SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
    FREQ   4_000_000
    ID   "SHIFTOUT"
    ' -------------------------------------------------------------------------
    ' IO Pins
    ' -------------------------------------------------------------------------
    Dpin   PIN  RA.0 OUTPUT ' shift data
    Cpin   PIN  RA.1 OUTPUT ' shift clock
     
    [b]Lpin   PIN  RA.2 OUTPUT ' latch it[/b]
    
    LEDs            VAR     RB
    TRIS_LEDs       VAR     TRIS_B
    ' -------------------------------------------------------------------------
    ' Variables
    ' -------------------------------------------------------------------------
    tmpB1   VAR  Byte
    i  VAR Byte
    ' =========================================================================
     PROGRAM Start
    ' =========================================================================
    Start:
      TRIS_LEDs = %00000000
      DO
        FOR i = 0 to 255
         SHIFTOUT Dpin, Cpin, LSBFIRST, i
                LEDs = i 
         PAUSE 1000   
     
         [b]Pulsout Lpin, 1[/b]
       
        NEXT
      LOOP
    
Sign In or Register to comment.