HSPIOUT not workin on 20X2

gbrusseau

Senior Member
I am trying to send serial data out the hardware HSPI SDO pin with no luck. I have a 20X2 PICAXE and using Program Editor version 5.3.6 and have some test code:

W0=4095
HSPISETUP spimode00,spifast
STRT:
HSPIOUT (B1,B0)
pause 1
goto STRT

Putting the scope probe on the SDO and CLK, all I see on my scope is what appears to be a PICAXE reset every 2.3 seconds. No serial data stream at all. The Basic Command document states that the SDI pin must be in the default state (whatever that means!), so I have pinned SDI to 0 volts and have also tried pinning SDI to +5 volts thru a 10K resistor, but still no data stream. Just the PICAXE reset every 2.3 seconds. The HSPI SDO pin is not connected to anything except my scope probe. What am I doing wrong.

From the Basic Command manual:
"Due to the internal operation of the microcontrollers SPI port, a hspiout
command will only function when the hspiin ‘input pin’ is in the expected
default state. If this pin is incorrect (e.g. high when it should be low), the hspiout
byte cannot be sent (as the microcontroller automatically detects an SPI error
condition). After 2.3 seconds of fault condition the PICAXE microcontroller will
automatically reset."
 
Last edited:

gbrusseau

Senior Member
After a second search, I found where the 20X2 PICAXE has a glitch with HSPI. Recommends setting pin B.7 (HSPI CLK pin) as an output after the HSPISETUP command. Will try that when I get home.

W0=4095
HSPISETUP spimode00,spifast
output B.7
STRT:
HSPIOUT (B1,B0)
pause 1
goto STRT
 
Last edited:

Janne

Senior Member
Also, check that the SPI input pin on the 20x2 is not floating. Otherwise, it might go into a loop forever waiting for the SPI bus to come available, and then the watchdog resets the chip after the 2.3s delay.
 
Top