MCP23S17 init all outputs and to a logic 1


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,729


    Did you find this post helpful? Yes | No

    Default Re: MCP23S17 init all outputs and to a logic 1

    from data sheet


    Serial Data to Output Valid— — 450 ns
    CS Setup Time 50 nS


    a 3mS pause is way to long


    SetPort_A:
    OutA_hi=OutA.highbyte 'Splits into hibyte
    OutA_lo=OutA.lowbyte 'And into low byte of the word var
    OutA_MCPReg = OLATA 'Sets up PORTA output
    OutA_DataOut=OutA_lo 'Sets up data to be pushed to the MCP23S17 as the low byte
    gosub SEND_OutA_2317 'Send it
    pause 3 'Wait a bit cannot see that this is necessary or even adds any value
    OutA_MCPReg = OLATB 'Sets up PORTB output
    OutA_DataOut=OutA_hi 'Sets up data to be pushed to the MCP23S17 as the hi byte
    gosub SEND_OutA_2317 'Send it
    return

    if you want speed why set only 1 bit at a time when they all are going to be set anyway

    for i=0 to 15 : OutA.0[i]=1 : gosub SetPort_A : next i
    Code:
    OutA=$ffff
    gosub SetPort_A
    would be 15 times faster

  2. #2
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: MCP23S17 init all outputs and to a logic 1

    Thanks Richard!
    I get caught up thinking in terms of 8 bits that I forget that I can actually speak in words! Hah!
    I did miss the PAUSE statement and have changed it to PAUSEUS 10 and it seems happy.
    I used the OutA=$FFFF : gosub SetPort_A and it seems that it too fast for the outputs to actually toggle which is what I was driving for.
    Thanks again, good eye and quite helpful.
    Steve
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

Similar Threads

  1. Need to flip order of bits MSB to LSB re: MCP23S17
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th May 2015, 01:42
  2. LCD init code ...safety
    By jorge in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th February 2011, 13:53
  3. init PORTD FOR 16F877A
    By coss_cat in forum General
    Replies: 3
    Last Post: - 19th June 2010, 17:16
  4. Init
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st April 2007, 01:43
  5. do i need to init the CG or DD in 4 bit lcd?
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th May 2005, 02:18

Members who have read this thread : 0

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