S12G SPI polarity control

cancel
Showing results for 
Search instead for 
Did you mean: 

S12G SPI polarity control

213 Views
DustyStew
Contributor V

The SPI MOSI pin defaults to high. So when no data is being sent, it goes high. I would like it to be low.

 

So I had a look at the Port Integration section of the Reference Manual, and it seemed this should be possible. The settings would be: wire-or mode, pull enabled, pulldown i.e. for MOSI on port 0:

 

WOMS &= ~0b00100000;  // set PS5 to wire-or mode

PERS  |= 0b00100000; // enable pull resistor on PS5

PPSS |= 0b0010000; // pull down

 

I'm afraid this doesn't work. I assume that is because these configuration bits do not apply when using the pins as SPI.

 

Or have I made an error?

Any other way to make the default state of MOSI low?

 

TIA

Labels (1)
0 Kudos
3 Replies

36 Views
iggi
NXP Employee
NXP Employee

Hi,

David is right. You must disable the SPI. Also you should set the Port Data Direction Register (DDRS for example) as output. I've tested this on DEMOAX9S12XEP100 board. See screenshots below (click on them to enlarge):

1. Initial state. SPI module initialized, but not enabled yet. The yellow marked address in memory window shows Port S Data Register (PTS) at 0x0248, Port S Input Register (PTIS) at 0x0249 and Port S Data Direction Register (DDRS) at 0x024A address.

As you can see Port S is set as input and PTIS reflects the buffered state on the pin which is 0xFC (taken from the PTS register). The MOSI pin (PS5) is logic 1.

Initial Port S state.JPG

2. SPI enabled. Port S dedicated to SPI module.

SPI enabled, Port S as input.JPG

3. Port S set as output. SPI still enabled. the PTIS reflect the 4 SPI pin status: MOSI and MISO are high.

PortS as output, SPI enabled.JPG

4. SPI disabled. Finally, PS5 (MOSI) pin is low as well as other Port S pins.

PortS as output, SPI disabled, pin low.JPG

5. SPI enabled again. Doublecheck the Port S status. MOSI/MISO pins are high again.

SPI enabled, MOSI pin high.JPG

Regards,

iggi

0 Kudos

36 Views
davezawislak
Contributor II

In SPICR1 after your SPI session is complete, set SPE to 0. This will take SPI off the buss and allow IO control over the pin.

36 Views
steph
Contributor I

hello,

how have you configure the SPI module (SPICR1, SPICR2, SPIBR...) ?

your problem must be in the configuration of the module.

0 Kudos