|
Post by dynamitron on Apr 27, 2020 19:32:17 GMT
Hello,
I am trying to set up an SPI communication to a chip using the BOARD_SOFT_SPI_SS2 (SPI only p53 chip select. MISO = p50, MOSI = p51 SCK = p52).
I have no success to get a correct signal for the MOSI pin 50. It looks like is staying in tri-state like it was not correctly set as an output. I have very tiny pukse (about 0.5V) at a level of 5V. The pulse are not going to zero
I have tested the pin as an ouptut with a simple program and it is ok.
When I do a SPI transfer, I use the instruction like this : SPI.transfer(BOARD_SOFT_SPI_SS2,reg)
Any hint ?
what am I missing ? Should I define the role of the SPI pins somewhere ? Is there a complete exemple the BOARD_SOFT_SPI_SS2 somewhere because I did not find anything in the examples.
Thanks in advance for the help
|
|
|
Post by dynamitron on Apr 28, 2020 20:22:38 GMT
So bad that I did not received any answer up to now even nothing from HITEX which I tried to contact trough the official website. At the end I found by myself, I can just say that tc275 doucmentation has a very deep lack of information about SPI.
I even use a SPI not listed in the doc (BOARD_SPI_SS2), found by looking deeply in the lib files....  : All other mode than BOARD_SPI_SS2 are just bullshit to use.
Here is my very simple test program :
#include "SPI.h"
//#define SPI_channel BOARD_SPI_SS0 /* CS = 10 MISO = P201.1, MOSI = P201.4 SCK = P201.3 */ //#define SPI_channel BOARD_SPI_SS0_S1 /* CS = 10 MISO = p12, MOSI = p11 SCK = p13 */ //#define SPI_channel BOARD_SOFT_SPI_SS0 /* CS = 10 MISO = p50, MOSI = p51 SCK = p52 */ //#define SPI_channel BOARD_SOFT_SPI_SS2 /* CS = 53 MISO = p50, MOSI = p51 SCK = p52 */ //#define SPI_channel BOARD_SPI_SS1 /* MISO = P201.1, MOSI = P201.4 SCK = P201.3 */ #define SPI_channel BOARD_SPI_SS2 /* Not used yet --- CS = 53 MISO = p50, MOSI = p51 SCK = p52 */
#define _cs 9 byte count ; byte count2;
void setup() { SPI.begin(SPI_channel); pinMode(_cs, OUTPUT); } void loop() { count++; count2 = 256-count; SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE1)); digitalWrite(_cs, LOW); SPI.transfer(SPI_channel,count,SPI_CONTINUE); SPI.transfer(SPI_channel,count2,SPI_LAST); digitalWrite(_cs, HIGH); SPI.endTransaction(); delay(100); }
|
|
|
Post by Admin on Apr 28, 2020 20:41:46 GMT
This is strange. We will check the soft SPI driver!
|
|
|
Post by Admin on Apr 29, 2020 9:10:25 GMT
Hi,
Your test program works fine on our rig with BOARD_SPI_SS2. However this will only work on boards of revision 4269.03.06210_B1 or later. The BOARD_SOFT_SPI_SS2 also works and this is OK for any board revision. The _cs must be the same as the SPI channel chosen. Here is your example:
#include "SPI.h"
//#define SPI_channel BOARD_SPI_SS0 /* CS = 10 MISO = P201.1, MOSI = P201.4 SCK = P201.3 */ //#define SPI_channel BOARD_SPI_SS0_S1 /* CS = 10 MISO = p12, MOSI = p11 SCK = p13 */ //#define SPI_channel BOARD_SOFT_SPI_SS0 /* CS = 10 MISO = p50, MOSI = p51 SCK = p52 */ #define SPI_channel BOARD_SOFT_SPI_SS2 /* CS = 53 MISO = p50, MOSI = p51 SCK = p52 */ //#define SPI_channel BOARD_SPI_SS1 /* MISO = P201.1, MOSI = P201.4 SCK = P201.3 */ //#define SPI_channel BOARD_SPI_SS2 /* Only for board revision 4269.06210_B1 or later --- CS = 53 MISO = p50, MOSI = p51 SCK = p52 */
#define _cs SPI_channel /* Was 9. Needs to be the same as the SPI channel */ byte count ; byte count2;
byte volatile RxData;
void setup() { SPI.begin(SPI_channel); pinMode(_cs, OUTPUT); }
void loop() { count++; count2 = 256-count; SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE1)); digitalWrite(_cs, LOW); RxData = SPI.transfer(SPI_channel,count,SPI_CONTINUE); RxData = SPI.transfer(SPI_channel,count2,SPI_LAST); digitalWrite(_cs, HIGH); SPI.endTransaction(); delay(100); }
|
|
|
Post by dynamitron on May 2, 2020 8:32:17 GMT
hello admin,
A) how do I know the version of my board ? B) not sure I agree with yourr last post :
I have define _cs as pin 9 on purpose in order to interface with my sensors. So, let’s keep it like that because I recombine it with pin53 later in my electronics.
With this said, when I choose BOARD_SPI_SS2, I see that pin 53 (cs) is correctly activated in my simple example.
The pin 53 is de/activated by the instructions "endTransaction" and "beginTransaction". If I remove these isntructions, the pin 53 is no more activated.
Indeed if I define _cs as SPI_channel it works also but I think it is a double activation and it works also.
Then with the same simple script, if I switch from BOARD_SPI_SS2 to BOARD_SOFT_SPI_SS2, the SPI pins are going crazy, specialy the clock and cs. If I have some time, I will push some screenshots of my scope here.
C) Nothing clear in the documentation about SPI speed. How is it related to the board clock ? For now I can just see that indeed changing the speed change the SPI clock.
|
|
|
Post by Admin on May 4, 2020 15:22:27 GMT
The board version is marked on the underside under the double row connector. It be something like "469.03.06210_B1".
The BOARD_SPI_SS2 channel will control the chip select (p53) automatically if you use the "SPI_CONTINUE mode. If you only use SPI_LAST, it will not control the chip select and you can use both 53 and 9 as separate chip selects. The Baudrate is around 4MHz in soft SPI mode.
The software SPI BOARD_SOFT_SPI_SS2 can only work with one chip select i.e. p53. This could be changed if it is a problem.
|
|