cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103xxx and STPM01

jedlb
Associate II
Posted on July 21, 2009 at 06:35

STM32F103xxx and STPM01

9 REPLIES 9
jedlb
Associate II
Posted on May 17, 2011 at 13:17

Dear Sir

I am agonized how to with HW and SW connection of SPI of STM32F103xxx and SPI of STPM01 IC. Is there some example for it or can somebody give me an advice

Thank you.

Bohdan

:-[

st3
Associate II
Posted on May 17, 2011 at 13:17

So what, exactly, is ''agonising'' you here?

The HW connections should be pretty straightforward.

There are SPI examples included in the STM32 FWLib.

jedlb
Associate II
Posted on May 17, 2011 at 13:17

Dear Sir

I know SPI signals like SCK (clock from host), MOSI (master output slave input), MISO (master input slave output),

NSS (slave riquest) and optionaly CS ( chip select).

********************************

Datasheet STPM01 10853.pdf paragraph 8.21

Four pins of the device are dedicated to this purpose: SCS, SYN, SCLNCN, SDATD. SCS, SYN and SCLNLC are

all input pins while !!!!SDATD can be input or output according if the SPI is in write or read mode.!!!!

SCS pin enables SPI operation when low. When SCS is low the SYN pin status select if the SPI is in read (SYN=1) or write mode (SYN=0). When SCS is high and SYN is also high the results of the input or output data are transferred to the transmission latches.

SCLNLC: clock input

SDATD is the Data pin. If SCS is low, the operation of SDATD is dependent on the status of SYN pin. if SYN is high

SDATD is the output of serial bit data (read mode) if SYN is low SDATD is the input of serial bit data signal (write mode). If SCS is high SDATD is input of idle signal.

It is quite diferent from STM32 SPI port

*************************************************

STPM01 Manual 11230.pdf paragraph 3.1

SPI master is implemented as a microprocessor

SCS and SYN are normally driven from some parallel port

while SCL and SDA are normally driven from some port to which an internal SPI peripheral unit is connected. This means that the SPI peripheral unit of the microprocessor should operate as a 2-wire SPI.

the SDA of P1 should be connected to SDI of the microprocessor. The writing functionality should be emulated or, a 3-state buffer, controlled by SYN, should be used in order to connect an SDO to the SDA.

It is horrible.

**************************************************************************

I will accept emulated SPI if something available for STM32. A strip of code in C will encourage me.

Thank you

Best Regards

:o

jj
Associate II
Posted on May 17, 2011 at 13:17

We ''now'' understand/agree with your agony.

Your ''SPI-accessory'' device is the culprit - it inflicts great complications due to its use/need for ''non-standard'' SPI signals.

As you write (or quote) several of these non-standard signals must come from STM32's GPIO.

I see 2 major complications:

a) STM32's long-documented failure to provide ''normal/customary'' automatic hw NSS-CS signal

b) apparent use of single pin to serve as ''both'' SPI dat out and dat in. I believe there is a mode of SPI operation in which ''only one signal line'' can be employed - first as input and then switching to output. In my experience this is a rarely used mode (due to complexity) and I don't know if ST has any illustrating examples.

If you really must use the offending ''SPI-like'' device you must agonize further. The alternative is to use a ''real SPI'' device - but recall the STM32's ''unique'' NSS-CS ''feature.''

jedlb
Associate II
Posted on May 17, 2011 at 13:17

Thank you for your interest. I am using STM32F103xx processor and I did not see how to configure SPI port like 2wire. I compared several ST design and I think that they use emulated SPI. Do you know some?

I also found AN2159 SPI Communication for comprehensive energy reading of the STPM01 but in this also SPI comm is in cloud.

Next I will study all in STEVAL-IPE006V2. There is all, gerber,schematic, firmware and PC SW in source. I hope I will try solution for me.

Best Regards

Note: I have absorbed horror like this with ST7540. One mode works with SPI and other with RS232 on the some pins.ST should have provide step by step doc for its some periphery or to have more fast support.

:-?

slawcus
Associate II
Posted on May 17, 2011 at 13:17

STPM01 uses single wire SPI. SDA is bidirectional. SCS is used for chip selection, SYN for write/read mode and data latch while in read mode. It can be used as normal SPI peripherial device with sw chip select. It can be used with two wire SPI and DMA. No problems at all.

I realy don't know why you complicate so much about hw nss? Many mcus doesn't have hw control of this signal.

jedlb
Associate II
Posted on May 17, 2011 at 13:17

I think NSS signalize to host request for transfer so that the host can start clock. I read there is some bug in STM32Fxxx.

Best regards.

😉

slawcus
Associate II
Posted on May 17, 2011 at 13:17

Even if MCU is master and peripherial IC is slave SPI device you must adapt master to the slave and not vice versa. There are many peripherial ICs and there are as many different protocols. Study the peripherials first then adapt MCU examples to it.

It's funny that you are using ST7540 🙂 I used ST7538 (not recommended for new design) and STPM01. Do you plan to build yourself AMR meter? 🙂 Hobby or professional?

[ This message was edited by: slawcus on 16-07-2009 15:21 ]

jedlb
Associate II
Posted on May 17, 2011 at 13:17

Energy metering is only one smaller part of my application.