Menu

Conflict between two SPI devices

Help
2015-11-09
2015-11-11
  • David Stephenson

    I am trying to operate two spi devices on the same data/clock lines (but different CS pins).
    One device is a display using the ILI9340 GCB library. The other is an SD card.
    The display will not initialize with the SD card inserted. It seems like the GLCD goes into some kind of initialization routine after the #define lines before the SD CS can be disabled.
    The SD card can be inserted after initialization and everything on the display seems to work.
    Writing to the SD card however does not happen.
    Any ideas?
    I could use the secondary SPI pins for the second device I suspose, but it would mean more wiring.

     
  • Anobium

    Anobium - 2015-11-09

    Hello,

    The ST7735 GLCD works with the SD Card I have here. I can check out the ILI9340 driver later,if needed.

    What SD Card driver are you using? I have not release the one I have on development here but it does work with the ST7735 but the initialisation was not the simpliest.

    What version of Great Cow Basic compiler are you using? We did fix some core issues to support the SD Card I have in development. So, you will need the latest code.

     
  • David Stephenson

    I am using my own SD routine (which works when there are no pin conflicts).
    The other problem I am having is that the display is turned on by the 16F1788. The problem is that the command to turn on the power is executed after the GLCD initialization in the compiled ASM despite being before in the basic code. So the power is turned on during intialization and the screen comes up half black half white.

     

    Last edit: David Stephenson 2015-11-09
  • Anobium

    Anobium - 2015-11-09

    Can you zip up the code? It looks like a issue with the iniitialisation process. The order of your code. I did some thinking to get the code to work as required.

    I have just tested here. Notice the the SD Card does not show here, this is in the main code

    ;Start of program memory page 0
        ORG 71
    BASPROGRAMSTART
    ;Call initialisation routines
        call    INITSYS
        call    INITSDGLOBALS
        call    INITTERMINALUSART
        call    INITGLCD_ILI9341
        pagesel $
        call    INITUSART
    

    Which comes much later.

    ~~~~~
    ;InitSD
    call INITSD
    ;Find first partition sector
    ;Dim PartStart As Long
    ;PartStart = SDFindPartition(1)
    movlw 1
    banksel SDPARTITION
    ~~~~~

     
  • David Stephenson

    I've attached the important bits of the program.
    I've tested the sdwrite subroutine and it works on its own (it writes two 512 byte blocks).
    I am going to try the alternate pins for spi (by setting AFPCON1) and see what happens.

     
  • Anobium

    Anobium - 2015-11-09

    Can you post a little bit of code that I can compile? I am getting batemp=baoutl(i) errors. Send me your ASM also.

    I have just soldered a connection to the SD Card on my ILI9341 display. I am getting the display and the sd card responding but the code, of course, is radically different. I have shared connection with the CS on different ports.

     

    Last edit: Anobium 2015-11-09
  • David Stephenson

    I've wired the SD to the alternate pins (portb.5,6,7). Now the display will work with the card in. Some writing to the card has happened as well (only one 512 byte block transfered instead of 2, but thats probably my coding error).
    Is there any trick I need to employ with the CS lines they seem to behave strangely maybe that is where I am getting the problems.
    As I understand it CS needs to be low to activate the device for SPI, and high to disable, but find I have to pull them low again or I get a current leak through the device.

     
  • David Stephenson

    Anobium,
    Can you post your INITSD routine? I am still not getting things to work it seems that the SPI settings for the display will not work with the SD card.

     
  • Anobium

    Anobium - 2015-11-11

    @David. Yes. It will be Friday evening before I can do this.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.