STM32F103CB Dual SPI

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
sgt_johnny
Posts: 7
Joined: Mon Jun 20, 2016 5:19 am

STM32F103CB Dual SPI

Postby 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?

User avatar
Pito
Posts: 606
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: STM32F103CB Dual SPI

Postby 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
Posts: 7
Joined: Mon Jun 20, 2016 5:19 am

Re: STM32F103CB Dual SPI

Postby 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
Posts: 722
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103CB Dual SPI

Postby stevestrong » Wed Jan 18, 2017 1:16 pm


sgt_johnny
Posts: 7
Joined: Mon Jun 20, 2016 5:19 am

Re: STM32F103CB Dual SPI

Postby 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.

Code: Select all

 DOG.initialize(10,0,0,9,4,DOGM128);   //SS = 10, 0,0= use Hardware SPI, 9 = A0, 4 = RESET, EA DOGM128-6 (=128x64 dots)


in the corresponding library i found this:

Code: Select all

void dog_7565R::initialize(byte p_cs, byte p_si, byte p_clk, byte p_a0, byte p_res, byte type)
{
   byte *ptr_init; //pointer to the correct init values
   top_view = false; //default = bottom view

   dog_7565R::p_a0 = p_a0;
   pinMode(p_a0, OUTPUT);
   spi_initialize(p_cs, p_si, p_clk); //init SPI to Mode 3

   //perform a Reset
   digitalWrite(p_res, LOW);
   pinMode(p_res, OUTPUT);
   delayMicroseconds(10);
   digitalWrite(p_res, HIGH);
   delay(1);

   //Init DOGM displays, depending on users choice
   ptr_init = init_DOGM128; //default pointer for wrong parameters
   if(type == DOGM128)       ptr_init = init_DOGM128;
   else if(type == DOGL128)    ptr_init = init_DOGL128;
   else if(type == DOGM132)    ptr_init = init_DOGM132;
   
   dog_7565R::type = type;

   digitalWrite(p_a0, LOW); //init display
   spi_put(ptr_init, INITLEN);

   clear();
}



If it not work with this library, does anybody know how i could modify it?

zmemw16
Posts: 974
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: STM32F103CB Dual SPI

Postby 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
Posts: 7
Joined: Mon Jun 20, 2016 5:19 am

Re: STM32F103CB Dual SPI

Postby 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
Attachments
dog_7565R.cpp
(10.5 KiB) Downloaded 13 times

stevestrong
Posts: 722
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103CB Dual SPI

Postby 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.
Last edited by stevestrong on Fri Jan 20, 2017 2:59 pm, edited 2 times in total.

User avatar
Pito
Posts: 606
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: STM32F103CB Dual SPI

Postby Pito » Fri Jan 20, 2017 11:46 am

Also mind the SPI1 could run 2x faster than the SPI2..

User avatar
mrburnette
Posts: 1766
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: STM32F103CB Dual SPI

Postby 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



At this moment, I know of no one on the forum using the DOG display. Essentially, it is similar to any graphic LCD except this display supports 8 pages.

Download the Core code from github: https://github.com/rogerclarkmelbourne/Arduino_STM32

Select Maple Mini as the board type. Do a test compile of the "DOG display example code"... you don't need hardware for this, but it will give you an idea of the amount of work effort necessary on your part.

I've used a variety of OLED, Nokia 5100, ILI93xx displays and not had an issue. I've used both SPI channels and SPI + DMA. But nothing is going to prepare you better than to just get the software example set-up and to do a test compile.

My guess is that the effort is certainly do-able, but as you have no STM32 experience, I do think you will need to allocate some serious time to getting to know the STM32F103xx uC.

Ray
My Projects

PS:
In giving this some thought, I would also recommend you invest $7 (2x $3.50) in acquiring 2 Maple Mini boards from Baite in China. Everyone who wants to play in this forum should have 2 of the Baite Maple Mini boards ... one to play with and one to use as a backup for testing possible hardware issues with the first board.
https://www.aliexpress.com/store/produc ... 82373.html
Note: single quantity of this board was only shown when I logged-into the site.


Return to “Generic STM32F103”

Who is online

Users browsing this forum: No registered users and 3 guests