1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Connecting 5110 LCD to PIC with SPI

Discussion in 'Oshonsoft' started by camerart, Oct 5, 2017.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    When controlling SPI on a PIC an address is used, I follow this example from the Oshonsoft manual:
    When connecting a 5110 module, which doesn't have addresses, how do I write an Oshonsoft program using one?
    Camerart.
     

    Attached Files:

    • spi.jpg
      spi.jpg
      File size:
      16.8 KB
      Views:
      18
    • 5110.png
      5110.png
      File size:
      20.9 KB
      Views:
      19
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    I would not send the address line, just the 'data' as there is only the 5110 on the SPI Bus.

    Found a couple of 5110 PDF's may be useful background info.
    E

    You could check this by using the Osh Scope feature.
    spi.jpg
     

    Attached Files:

    Last edited: Oct 5, 2017
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    A quick checks, it looks OK to me.
    E
     

    Attached Files:

    • A02.gif
      A02.gif
      File size:
      36.7 KB
      Views:
      18
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.

    Hi E,
    OK, that's good, thanks.
    I'm trying to write a function, taken from a previous program, here it is not working in the attached program. I've got in a tangle.
    C.
     

    Attached Files:

  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    Is the error msg that you get in Oshonsoft.?
    The command is too complex for Osh to understand.

    Have you read pages 6 thru 9 of the User PDF I posted.

    E
     

    Attached Files:

    • A02.gif
      A02.gif
      File size:
      14.7 KB
      Views:
      17
  7. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    Try these options, note maximum of 5 args.!
    I have not studied the 5110 but I would have thought you need to somehow address a register with the SPI befor loading the command/data.???

    In the FUNCTION/PROC you should have
    SPISend arg1
    SPISend arg2 ''
    etc.........

    E
     

    Attached Files:

    Last edited: Oct 5, 2017
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.
    I have not studied the 5110 but I would have thought you need to somehow address a register with the SPI befor loading the command/data.???
    Hi E,
    I'm not sure, as I'm copying an existing program into Oshonsoft.

    I tried various combinations and this works on the Oshonsoft Oscilloscope.
    Thanks.
    C.
     

    Attached Files:

    Last edited: Oct 5, 2017
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    If you check your scope image it appears that every other block of clock pulses is carrying no data.??
    The SPIPrepare should be part of the main code, not be within the Proc.
    Try it.
    E
     
  10. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    Done! Looks better.
    Thanks.
    C.
     
    Last edited: Oct 6, 2017
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    I have run your post #7 program, I get nothing like the scope image you have posted.??
    E
     
  12. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    Are your Oscilloscope PORT settings the same as mine?
    C.
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Yes
    E
     
  14. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    I just downloaded and copied the #7 program directly into Oshonsoft, and still the Oscilloscope works for me.
    Mystery.
    C.
     
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi.
    I read the PIC type as 18F2550 not 18F2520... woops.!!!:(
    I quick try shows a better reult
    Will try again in detail after lunch.
    E
     
  16. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    I'm surprised at you! I never make mistakes:cool:
    C.
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    Hi C,
    A quickie before lunch shows data for every CS when the SPIPrepare is moved from the PROC to earlier in the code as it should be.

    I make mistakes often, I am a human.!

    E
    A02.gif
     
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    Checking your program it will not work as you expect, partly due to Osh.
    Look at this alternative using Const, much tidier, also Osh is happy using names in Proc/Func
    Run it twice, once as Write and another as Read
    I have assumed an address method of 0x01, but as said, I have not studied the 5110

    E
     

    Attached Files:

  19. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    270
    Likes:
    15
    Location:
    Helsinki, Finland
    5110 uses oneway SPI , only spi clock and sdo are needed.
    Spi address is not used.
    Addionally from PIC: D/C , reset, chip select.
    I am not sure, but probably chip select can be constantly on.
     
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    A quick scan thru of the 5110 d/s shows that the as far as the SPI is concerned, it is Write Only as jjw points out.

    So for the SPI Write just follow this simple flow chart, ensure that Rst and D/C are correctly set first.
    E
    A05.gif
     
  21. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,421
    Likes:
    11
    Location:
    Dorset UK.

Share This Page