PIC18F458 Shiftin / Out


Closed Thread
Results 1 to 5 of 5
  1. #1
    pberhin's Avatar
    pberhin Guest

    Default PIC18F458 Shiftin / Out

    Something wrong with the Shiftin Shiftout

    I have the following problem with the shiftin / out function.
    Pic used is a 18F458

    I used the port D to control an ADC Converter LTC1298 (D4-D7)
    and 2 relays (D3 D4) and leds (D0 D1)

    LEDNIGHT_Status VAR PortDStatus.0
    LEDDAY_Status vAR PortDStatus.1
    RELAYNIGHT_Status VAR PortDStatus.2
    RELAYDAY_Status VAR PortDStatus.3
    CS_Status VAR PortDStatus.4
    SCLK_Status VAR PortDStatus.5
    DIN_Status VAR PortDStatus.6
    DOUT_Status VAR PortDStatus.7
    All defined as out except PortD.6

    To read the ADC value, I used the following command

    CS_Status = 0
    PORTD = PortDStatus 'Activate the ADC.
    shiftout PORTD.7,PORTD.5,lsbfirst,[config\4] 'Send config bits.
    shiftin PORTD.6,PORTD.5,msbpost,[Temp_VOLT\12] 'Get data bits.
    CS_Status = 1
    PORTD = PortDStatus 'Deactivate the ADC.


    This works fine but if one of the ouptut D0-3 is set to 1 before the statement, the output will follow the CS_Status during the shifout or shiftin
    statement.

    Any idea ?

  2. #2
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    In your programm, we see no definition of "PortAStatus" !

    Why do you put this undeclared value to PortD ?
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  3. #3
    pberhin's Avatar
    pberhin Guest


    Did you find this post helpful? Yes | No

    Smile 18F456 shiftin shiftout

    I don't use the Port A, so ..

    I just tried with another PIC just to see if I didn't had one hardware problem : just the same
    I then tried with a 18F452 instead of a 18F458.
    With this one , everything just works fine ....

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you need to disable analog comparator on PORTD<3:0> to avoid odd results first.
    CMCON=7

    about now?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    pberhin's Avatar
    pberhin Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    You're right. I forgot this.
    I tried again with the 458. It's works fine
    Thanks

Similar Threads

  1. Shiftin question
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th November 2007, 19:09
  2. SHIFTIN problem
    By champion in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th January 2007, 03:31
  3. SHIFTIN clock pin???
    By champion in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd January 2007, 18:41
  4. Can anyone help me to use Writecode for pic18f458 ?
    By dip1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th June 2006, 22:29
  5. Using SHIFTIN
    By TonyA in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st May 2006, 15:38

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts