A-Star 32U4 prime SPI slave problem

Hello,

I have a problem with the a-Star Prime in acting as SPI slave. SS pin (PB0) is always HIGH.

pinMode(SS, INPUT);

digitalWrite(SS, LOW);
Serial.println(digitalRead(SS)); <- always return 1

How can I force/ control LOW state of SS pin ?

Pushing C button helps a bit, I can see SPI communication.

Thanks,
Dominik

Hi, Dominik.

Both the SV and the LV versions of the A-Star Prime have the on-board red LED and a current limiting pull-up resistor for it attached to the PB0 pin, so its default state is high. Pushing the C button pulls that pin to ground through a 3k resistor.

The ATmeag32U4 does not have internal pull-down resistors (only pull-ups), so your digitalWrite(SS, LOW); statement does not do anything while SS is declared an input. However, the salve select line should be controlled by the master anyway, so you should just make sure it drives SS low when it wants to communicate with the A*. Alternatively, if that is the only slave, you could just tie the PB0 line low with hardware and loose the functionality of the C button.

-Claire

Thanks for quick reply.

Wiring SS to the LOW pin () works, but I can observe bytes lost time to time (I had no such problem on UNO board with the same code)

So, I wonder if it’s possible to disable RXLED blinking on serial transmission ?

Regards,
Dominik

Since the 32U4 handles USB communication and some of the ISRs involved in that are fairly long, it is possible that is messing up the SPI timing once in a while. Could you first try disconnecting the A-Star from USB and seeing if the SPI communication becomes more reliable? As a side effect of disconnecting it from USB, it should stop blinking its RX led, but it’s still a good idea for your code to repeatedly set that pin to drive low in your loop function.

-Claire