-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem sharing SPI #19
Comments
Hi. `void updateIO() // 74HC595 Output + 74HC165 Input digitalWrite(latchPinI, LOW); digitalWrite(latchPinO, LOW); SPI.beginTransaction(SPISettings(hereWriteComSpeed, MSBFIRST, SPI_MODE0)); SPI.transfer(OutReg);//Transfer data SPI.endTransaction(); digitalWrite(latchPinO, HIGH); }` `void updateIO() // 74HC595 Output + 74HC165 Input digitalWrite(latchPinI, LOW); digitalWrite(latchPinO, LOW); SPI.beginTransaction(SPISettings(hereWriteComSpeed, MSBFIRST, SPI_MODE0)); InRegVariable = SPI.transfer(OutReg);//RW data SPI.endTransaction(); digitalWrite(latchPinO, HIGH); digitalWrite(latchPinI, HIGH); |
If you use in your code the |
Yes, scheme is similar. If i add SPI.begin(); at the end of my function, SD work, TFT work, but your library not work. void updateOut() // 74HC595 Output void updateIn() // 74HC165 Input void updateIO() // 74HC595 Output + 74HC165 Input pinMode(dataPinI, INPUT); |
Sorry, you're right with 74HC165, i read it now. That is really interesting, i have to think about it. |
Try to use `void updateOut() // 74HC595 Output SPI.end(); digitalWrite(latchPinO, LOW); pinMode(clockPin, OUTPUT); pinMode(dataPinO, OUTPUT); shiftOut(dataPinO, clockPin, MSBFIRST, OutReg); digitalWrite(latchPinO, HIGH); SPI.begin(); |
Adding SPI.end, TFT Stop Working |
Indeed, adding SPI.end whole program crashes and does not proceed further. |
Ok, solved prooblem of crash, but same, with SPI.end(), your library not work. If i test SD then CH376, or first CH376 then SD, always SD work, TFT Work, CH376 Not Work.
|
Same if i use But if i use |
Working on simplified program, library stop working after pinMode(clockPin, OUTPUT);
|
Please use a dedicated pin for interrupt request from CH376! |
In a first case |
I have no free pin for connect interrupt. But all other spi device work well. It is not a problem if spi is used on special way during flash operation. |
The datasheet only describes this 2 mode with SPI(MISO as INT or dedicated INT), INT is always required. Possible to change 74HC165 chip with other type with 3state dataOut pin?e.g 74HC589 , etc.? Because then you get one extra pin what you using now like MISO2. Or to use shift register to query interrupt request from the chip? If it's possible then i can change the library to be able to use variable instead of physical pin for sensing interrupt request. |
Yes, i can change IC. But before i try to connect INT for test. |
Never print Init.
|
That pin is not used elsewhere in your code? Or Serial2 is not initialized? |
And put all the other devices chipSelect pins to high |
Complicated to use HC589, has three control lines, I do not know if it can be reduced to one or two, I will buy someone to try. But If no chip are not welded, alt the program, you have to add timeout. |
Please don't stick to this chip, that was just an example(quick pick from Google), please try the AVRFreaks solution first(this is also just an advice, it can only works if you plan to use just one 74HC165 on the MISO line). I put together an SD card+ SD lib., W5100 + Ethernet lib., CH376 + this lib.,Arduino Uno + IDE 1.8.10 and the code doesn't stuck , but if i don't connect a ethernet cable to eth.module then it get stuck(for 1 minute, timeout). |
I tried to totally disconnect the module or just int line and the code doesn't stuck. I can't reproduce this bug. My hardware environment is different from yours, this can be also |
About Stuck I will do other tests. |
No problem, yes it can, so in the same time you send out and read bit's. |
The SPI.beginTransaction recommended to call before with the chipSelect pin you enable the chip itself. I don't used these chip's so i'm not familiar with them.
|
But this is a problem. |
That's right i can reproduce, i open a new issue for this bug. If the SPI bus sharing issue is solved then we can close this issue. Thanks |
SPI.begin();
flashDrive.init();
delay(1000);
if(flashDrive.checkDrive()) tft.println("Ch376 ok");
else tft.println("Ch376 fail");
If i add SPI.beghin() It does not work anymore
But if you do not add other devices do not work. SD, TFT, ecc.
Questo perchè uso i PIN SPI anche per IO Shif register.
void updateIO() // 74HC595 Output + 74HC165 Input
{
digitalWrite(latchPinI, LOW);
digitalWrite(latchPinO, LOW);
pinMode(clockPin, OUTPUT);
pinMode(dataPinO, OUTPUT);
shiftOut(dataPinO, clockPin, MSBFIRST, OutReg);
digitalWrite(latchPinO, HIGH);
SPI.begin();
}
The text was updated successfully, but these errors were encountered: