STM32F103CB Dual SPI

sgt_johnny
Wed Jan 18, 2017 12:22 pm
Hello

Im currently working on a prototype ATMEGA328 project and i’m a.) running out of pins b.) worry about SPI

I have do communicate with two SPI-Devices (SD-Card Mode 0) and (Display Mode 3). So to communicate i need to completly shut down communciation, change spi mode, and then restart with different values.

So i looked at STM32F103CB, which is used on mapple boards. It is not that much more expensive than an Mega328, and comes with 2 SPI. Are they supported by Arduino? Can i connect the SD Card on SPI1, and Display on SPI2? :)

I also need 2 pins for a GPS, that usually works by the SoftwareSerial library. And i need 1x I2C as well.

Is it possible?


Pito
Wed Jan 18, 2017 12:30 pm
Yes, you get 2xSPI, 2xI2C, 2xSerial – all could be used in your sketch at the same time..

sgt_johnny
Wed Jan 18, 2017 1:01 pm
Is there any tutorial/exmaple how i tell the SPI library that there is a second port, and which one sould be used?

stevestrong
Wed Jan 18, 2017 1:16 pm
See this example.

sgt_johnny
Thu Jan 19, 2017 6:03 pm
How can i find out if the used library works with a SPI2 object?

Here is my application:

This is the code in the .ino file of a example program written for arduino uno.
DOG.initialize(10,0,0,9,4,DOGM128); //SS = 10, 0,0= use Hardware SPI, 9 = A0, 4 = RESET, EA DOGM128-6 (=128x64 dots)


zmemw16
Thu Jan 19, 2017 6:33 pm
firstly read the faq, rtfm, learn the search engine for the site, use it, browse the forums, read anything that might help
repeat using github, maybe search for stm32f1 or stm32f, look at those repo’s that use your hardware or similar hardware
searching arduino on github is probably not a good idea – “We’ve found 72,931 repository results”

list the hardware you’ve got and/or thinking of getting

interfaces – list them and then for each, list the devices attached

are there arduino libraries for each and is there a stm32 port ( teensy / due / a.n.other) of those ?

dog128 is a display and there’s a tft or lcd mega package istr that has it in, rikki?? u8glib or utft ?? ?? ??

when you have that lot sorted out, then we might be able to help further.

btw if this is homework or a school / college / uni project – all bets are off.

stephen


sgt_johnny
Thu Jan 19, 2017 7:03 pm
Sorry, i might be have not provided enough info

The manufacturer of the DOG128 provided a working library for the arduino boards. See library attached
The code sniped i attached is from that library. My question is, if this would work with the second SPI port of the STM32. I have read about the SD-Card library not working with the stm32, because SPI1 is hardcoded in library and must be changed.

The display’s are expensive, so just buy and try it is the last option :(

Hadware i want to use: STM32F103 Chip, soldered to my own pcb
Interfaces: SPI: SD Card , SPI2: DOG128 Display, I2C: EEPROM,RTC, UART: to FT232 and then serial monitor

This is not for school or so, its for hobby. I usually use mega328, but in this project i need 2 SPI and more pins, so i’m looking at the STM32F103 since i can arduino code on there and its not really much more expensive than Mega328


stevestrong
Thu Jan 19, 2017 7:28 pm
Use the new SDFat beta (search it on github and read the specification), it can work with SPI 2. Then you can use SPI 1 for the display.

Pito
Fri Jan 20, 2017 11:46 am
Also mind the SPI1 could run 2x faster than the SPI2..

mrburnette
Fri Jan 20, 2017 1:22 pm
sgt_johnny wrote:Sorry, i might be have not provided enough info

The manufacturer of the DOG128 provided a working library for the arduino boards. See library attached
The code sniped i attached is from that library. My question is, if this would work with the second SPI port of the STM32. I have read about the SD-Card library not working with the stm32, because SPI1 is hardcoded in library and must be changed.

The display’s are expensive, so just buy and try it is the last option :(

Hadware i want to use: STM32F103 Chip, soldered to my own pcb
Interfaces: SPI: SD Card , SPI2: DOG128 Display, I2C: EEPROM,RTC, UART: to FT232 and then serial monitor

This is not for school or so, its for hobby. I usually use mega328, but in this project i need 2 SPI and more pins, so i’m looking at the STM32F103 since i can arduino code on there and its not really much more expensive than Mega328


BennehBoy
Thu Jan 26, 2017 8:56 am
If speed isn’t essential you can just use software SPI anyhow, I’m driving 3 ssd1306 displays from 1 software SPI bus and a MAX31856 on another, it’s lightning fast on a maple mini compared to a 328.

Obviously that doesn’t answer the library question directly, but if your screen library has a sw SPI option it’s more likely to work than HW imho.

Why that choice of display? SSD1306 OLED displays are super cheap, bright, great viewing angles, and 128×64 pixels are readily available.


Leave a Reply

Your email address will not be published. Required fields are marked *