electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Arduino
Arduinos cortex M3 at 2USD
Post new topic   Reply to topic
Page 1 of 2 [26 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: 1, 2 Next
Author Message
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Thu Dec 20, 2018 4:37 am    Post subject: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

Hi,

I have found this:

https://www.ebay.es/itm/1PCS-Arduino-IDE-kompatibles-Board-STM32-STM32f103C8T6-ST-ARM-32-bit-Cortex-M3/162707467072

Basicly is a arduino with cortex M3 at 2USD. So it´s like a teensy but costing peanuts. I wonder how it is possible and if someone has experience with this boards.

One of the drawbacks is that the XTal is 8Mhz... with does even less sense as the chip can run at 74Mhz.

Im about to order one and 74Mhz Xtals and try to run it at his top speed. Not sure if the voltage regulator is going to blown. Even if I have to change the regulator it seems like a bargain.

So if someone has insights or tips about it Im all ears
Back to top
View user's profile Send private message
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Thu Dec 20, 2018 5:31 am    Post subject: Re: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

MapacheRaper wrote:
One of the drawbacks is that the XTal is 8Mhz... with does even less sense as the chip can run at 74Mhz.


It probably has internal clock multiplication to make it run at multiples of 8 MHz, so no need to fix anything.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Thu Dec 20, 2018 5:51 am    Post subject: Reply with quote  Mark this post and the followings unread

Seen it on Alieexpress, is it compatible with the Arduino ide or just the pinout?
Delivery free of charge.
Any schematics at hand?


684D0BDF-D014-4DAE-8BEE-308C17057722.jpeg
 Description:
 Filesize:  172.97 KB
 Viewed:  504 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

684D0BDF-D014-4DAE-8BEE-308C17057722.jpeg



_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
ixtern



Joined: Jun 25, 2018
Posts: 145
Location: Poland

PostPosted: Thu Dec 20, 2018 6:35 am    Post subject: Re: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

MapacheRaper wrote:
Hi,

I have found this:

https://www.ebay.es/itm/1PCS-Arduino-IDE-kompatibles-Board-STM32-STM32f103C8T6-ST-ARM-32-bit-Cortex-M3/162707467072

Basicly is a arduino with cortex M3 at 2USD. So it´s like a teensy but costing peanuts. I wonder how it is possible and if someone has experience with this boards.

One of the drawbacks is that the XTal is 8Mhz... with does even less sense as the chip can run at 74Mhz.

Im about to order one and 74Mhz Xtals and try to run it at his top speed. Not sure if the voltage regulator is going to blown. Even if I have to change the regulator it seems like a bargain.

So if someone has insights or tips about it Im all ears


I have wasted some time with such board. In general it has very good relation power/price but very bad relation regarding required programming time.
In general: has free development environment (System Workbench for STM32), doesn't work directly with Arduino (some guys done it but it's not so easy). It is hard to programming, to proper configure all required options. And it is easy to permanently lost connection with chip after programming with ST-Link (due to some bugs) happened to me several times - some kind of reset is needed then.
Cannot even start simple timer from the generic examples with it (maybe I am not a good programmer). So I threw it away and changed to Teensy.
But you can try. If you master it, it may be cheap and powerful horse in the Arduino-like world. And yes, it can run with a full speed.
Back to top
View user's profile Send private message
ixtern



Joined: Jun 25, 2018
Posts: 145
Location: Poland

PostPosted: Thu Dec 20, 2018 6:40 am    Post subject: Reply with quote  Mark this post and the followings unread

And found a schematic. Although there were three or four versions...


STM32F103C8T6 Schematic.pdf
 Description:

Download
 Filename:  STM32F103C8T6 Schematic.pdf
 Filesize:  79.22 KB
 Downloaded:  627 Time(s)

Back to top
View user's profile Send private message
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Thu Dec 20, 2018 7:43 am    Post subject: Re: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
MapacheRaper wrote:
One of the drawbacks is that the XTal is 8Mhz... with does even less sense as the chip can run at 74Mhz.


It probably has internal clock multiplication to make it run at multiples of 8 MHz, so no need to fix anything.


I always learn something useful from you. I didn´t know that it was possible. Thanks!!
Back to top
View user's profile Send private message
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Thu Dec 20, 2018 7:52 am    Post subject: Re: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

ixtern wrote:
MapacheRaper wrote:
Hi,

I have found this:

https://www.ebay.es/itm/1PCS-Arduino-IDE-kompatibles-Board-STM32-STM32f103C8T6-ST-ARM-32-bit-Cortex-M3/162707467072

Basicly is a arduino with cortex M3 at 2USD. So it´s like a teensy but costing peanuts. I wonder how it is possible and if someone has experience with this boards.

One of the drawbacks is that the XTal is 8Mhz... with does even less sense as the chip can run at 74Mhz.

Im about to order one and 74Mhz Xtals and try to run it at his top speed. Not sure if the voltage regulator is going to blown. Even if I have to change the regulator it seems like a bargain.

So if someone has insights or tips about it Im all ears


I have wasted some time with such board. In general it has very good relation power/price but very bad relation regarding required programming time.
In general: has free development environment (System Workbench for STM32), doesn't work directly with Arduino (some guys done it but it's not so easy). It is hard to programming, to proper configure all required options. And it is easy to permanently lost connection with chip after programming with ST-Link (due to some bugs) happened to me several times - some kind of reset is needed then.
Cannot even start simple timer from the generic examples with it (maybe I am not a good programmer). So I threw it away and changed to Teensy.
But you can try. If you master it, it may be cheap and powerful horse in the Arduino-like world. And yes, it can run with a full speed.


Super useful info!! Yeah that makes a lot of sense... So is not arduino compatible, or not directly/easy way.

It´s a real shame, because the possibilities are huge. I myself Im quite a newbie in the arduino ecosystem and it´s the first time I hear about the System Workbench for STM32 so I don´t know how far I can reach.

I will try to run some basic sketches in case I manage to learn something interesting I will post it over here.

Anyway, for less that 2USD is not a great lost. The time and frustration is another history... Smile

Thanks for your feedback! Wink
Back to top
View user's profile Send private message
ixtern



Joined: Jun 25, 2018
Posts: 145
Location: Poland

PostPosted: Fri Dec 21, 2018 12:37 am    Post subject: Re: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

Quote:
Super useful info!! Yeah that makes a lot of sense... So is not arduino compatible, or not directly/easy way.

It´s a real shame, because the possibilities are huge. I myself Im quite a newbie in the arduino ecosystem and it´s the first time I hear about the System Workbench for STM32 so I don´t know how far I can reach.

I will try to run some basic sketches in case I manage to learn something interesting I will post it over here.

Anyway, for less that 2USD is not a great lost. The time and frustration is another history... Smile

Thanks for your feedback! Wink

You can try starting from this page:
https://wiki.stm32duino.com/forums.html?title=Blue_Pill
and this:
https://wiki.stm32duino.com/forums.html?title=Installation
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Fri Dec 21, 2018 7:59 am    Post subject: Reply with quote  Mark this post and the followings unread

Very nice, will bookmark this page Laughing
_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Sat Dec 22, 2018 6:25 am    Post subject: Re: Arduinos cortex M3 at 2USD Reply with quote  Mark this post and the followings unread

ixtern wrote:
Quote:
Super useful info!! Yeah that makes a lot of sense... So is not arduino compatible, or not directly/easy way.

It´s a real shame, because the possibilities are huge. I myself Im quite a newbie in the arduino ecosystem and it´s the first time I hear about the System Workbench for STM32 so I don´t know how far I can reach.

I will try to run some basic sketches in case I manage to learn something interesting I will post it over here.

Anyway, for less that 2USD is not a great lost. The time and frustration is another history... Smile

Thanks for your feedback! Wink

You can try starting from this page:
https://wiki.stm32duino.com/forums.html?title=Blue_Pill
and this:
https://wiki.stm32duino.com/forums.html?title=Installation


Bookmarket too. Thanks!!
Back to top
View user's profile Send private message
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Mon Dec 24, 2018 1:38 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi,

I have found a github with some examples that runs on the blue pill:

https://github.com/ChrisMicro/BluePillSound

My blue pill should arrive in a month or so, so Im in code accumulation mode
Back to top
View user's profile Send private message
gabbagabi



Joined: Nov 29, 2008
Posts: 651
Location: Berlin by n8
Audio files: 23

PostPosted: Tue Dec 25, 2018 4:05 am    Post subject: Reply with quote  Mark this post and the followings unread

even on the risk you guys will laugh on me:
is the 20k SRAM = 20k*8Bit |or| 20k*32Bit
?
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Tue Dec 25, 2018 5:15 am    Post subject: Reply with quote  Mark this post and the followings unread

20kBytes


https://www.st.com/resource/en/datasheet/stm32f103c8.pdf

I have ordered 2 to tinker with Laughing

_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
mosheen



Joined: Jun 19, 2013
Posts: 21
Location: NC

PostPosted: Tue Dec 25, 2018 11:50 am    Post subject: Reply with quote  Mark this post and the followings unread

I found that once I got the bootloader running on it and the Arduino tool-chain running correctly it was easy to program in the Arduino IDE. That may take you a bit of effort though since some of the guides don't match the libraries 1:1. Work on uploading the Blink LED example and once you get there you know that at least the IDE is setup.

https://wiki.stm32duino.com/forums.html?title=Installation
Back to top
View user's profile Send private message
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Wed Dec 26, 2018 6:36 am    Post subject: Reply with quote  Mark this post and the followings unread

g.gabba wrote:
even on the risk you guys will laugh on me:
is the 20k SRAM = 20k*8Bit |or| 20k*32Bit
?


Good question... I think memory bytes are always 8bit, but Im not dead sure Wink
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Wed Dec 26, 2018 6:48 am    Post subject: Reply with quote  Mark this post and the followings unread

While I've seen different definitions for "word", I've never seen a deviation from 8 bits for bytes when used as a specification for a CPU chip. In my experience, all devices with RAM, including FPGAs are spec'd in 8 bit bytes regardless of what the native data width might be. For example, 32 bit ARM chips are spec'd in bytes of RAM even though the RAM is organized in 32 bit words noting however, that the addressing system allows access to single 8 bit bytes. On some rare occasions in the serial data comm world, I've seen 9 bits spec'd for bytes because of the addition of a parity bit and for 10 bits when there are parity and/or device select bits added, but even there, the data portion is 8 bits. And there is the 7 bit "word" as well, often coupled with a parity bit, but again, this is serial data comm stuff, not a specification for a CPU chip. When the spec is just in K with no units, one usually assumes bytes, such as 20K which would be 20Kbytes unless the documentation specifies a unit elsewhere.
_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Sat Jan 12, 2019 12:52 pm    Post subject: Reply with quote  Mark this post and the followings unread

Ok, I received the blue pill, but it needs a dedicated 2usd programmer and a bit tedious first time booting "format". All is explained here:

https://www.youtube.com/watch?v=wGbiT6IxGP0

Now I understand why it costs 2€ and why people move to teensy or another platforms. It takes quite patience to get the thing running
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Sat Jan 12, 2019 3:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

I guess next week my blue pill will show up, I ordered an usb programmer to go with it (smart me Cool )
_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Sun Jan 13, 2019 6:50 am    Post subject: Reply with quote  Mark this post and the followings unread

Grumble wrote:
I guess next week my blue pill will show up, I ordered an usb programmer to go with it (smart me Cool )


Well done. I wasn´t as smarter and I will have to wait one more month for the programmer... grrr.

By the way the great scott has another video with the blue pill explaining how to boot it and some counters setup code(keywords: great scott smt32)

What do you plan to do with it?
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Sun Jan 13, 2019 6:52 am    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
What do you plan to do with it?


dunno yet Very Happy
I buy a lot of stuf just because I like to, and only later I figure what to do with it

_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Thu Apr 09, 2020 3:15 am    Post subject: Reply with quote  Mark this post and the followings unread

Good to know (I needed a good portion of a day to figure this out):
DO NOT USE PINS PB3 and PB4. By default, PB3 and PB4 are used for JTAG debugging
That said:

DISCLAIMER:
This is NOT a thorough description of the use of (parts of) the STM32103 Blue Pill, but merely a description of what I needed and how I used them eventualy.

I am working on a project using the Blue Pill STM32F103 and I thought it was a good idea to write something about this project in pieces anybody could use...

First of all, I use the Arduino IDE for this project, simply because the well.. simplicity and the huge amount of libraries online.
For programming I use the ST-link V2 connected to the 4 pins on the narrow side of the board.

In the attached txt file are the .ino files in txt format.

The first one: BLINK



Code:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  The LED on the Blue Pill is connected to PC13
*/


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin PC13 as an output.
  pinMode(PC13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(PC13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(PC13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

This is a good program to check if the ST-link is connected as should be and if the Arduino IDE is setup correctly.


blue pill.txt
 Description:
TXT file with the used programs

Download
 Filename:  blue pill.txt
 Filesize:  3.19 KB
 Downloaded:  137 Time(s)


_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Thu Apr 09, 2020 3:26 am    Post subject: Reply with quote  Mark this post and the followings unread

Since I'm using the Blue Pill for a sequencer, timing is essential so using an interrupt caused by a timer (timer2) is crucial.
What I do here is setting a timer to produce an interrupt and in the interrupt service routine (overflowISR() ) a flag is set and later in the main program the software is waiting for this flag to set and when it does the condition of the on board LED is inverted, resulting in a blinking LED with half the frequency of the interrupts caused by the timer.
This setting of a flag (timer_tick=true;) is the shortest possible interrupt service routine.

Code:

/*
 Timer Interrupt
 Using timer 2 to give a flag when an overflow occured.
 Use polling this flag to time programs
*/
uint16_t timer_value = 0x8FFF;
int prescalefactor = 400;
volatile bool timer_tick = false;//timer_tick is changed in the Interrupt Service Routine
HardwareTimer timer(2);
void overflowISR();


void setup() {
pinMode(PC13, OUTPUT);// here is the internal LED attached to
timer.pause();
timer.setPrescaleFactor(prescalefactor);
timer.setOverflow(timer_value);
timer.refresh();
timer.attachInterrupt(4, overflowISR);
}

void loop() {
  timer.resume();//start timer2
while(1){
  while(!timer_tick){} //poll for timer_tick
  timer_tick=false; //reset timer_tick
  digitalWrite(PC13, !digitalRead(PC13));//invert LED port
  }
}

void overflowISR()
{
  timer_tick=true;//here is the timer flag set
}

_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Thu Apr 09, 2020 3:29 am    Post subject: Reply with quote  Mark this post and the followings unread

Also I'm planning to use MIDI at some point of the design, and this is how I did this:
Very straight forward, one comment: the note off can be just a note on with a velocity of 0, or can be a true note off where the cmd byte is 0x80.

Code:

/*
 MIDI using the TX1 of UART1 at pin PA9 
*/

uint8_t channel = 10;//I used the percussion channel 10
uint8_t velocity = 64;// half max value
// plays a midi note on TX1 @ PA9
//check in calling routine for max cmd, pitch and velocity
void noteOn(char cmd, char pitch, char velocity) {
    Serial1.print(cmd);
    Serial1.print(pitch);
    Serial1.print(velocity);
}

void setup(void) {
pinMode(PA9, OUTPUT);// this is the TX1 pin
// Set MIDI baud rate to 31250 Bps:
Serial1.begin(31250);
}

void loop(void) {
while (1){
// Play notes from F#-0 (0x1E) to F#-5 (0x5A):
    for (uint8_t note = 0x1E; note < 0x5A; note++) {
         noteOn((0x90+channel), note, velocity);
        delay(10);
//noteOff can be this:
        noteOn((0x90+channel), note, 0x00);//velocity = 0x00 means noteOff
//or use for noteOff:
       //noteOn((0x80+channel), note, velocity);       
        delay(100);   
   }
  }
}


_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Thu Apr 09, 2020 3:51 am    Post subject: Reply with quote  Mark this post and the followings unread

What I think is great about using Arduino type of modules is the use of external components, and mostly I look for SPI controlled parts.
SPI because it is very fast, a drawback is that more pins are used compared to I2C.
It took some time to figure out how to proceed if the components I used needed different types of SPI configurations.
I found the answer to using:
Code:

SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE3));

I'm not sure how the 1000000 setting relates to the SPI bit-rate, what I am sure off is that the bigger this number, the higher the bit-rate (1000000 = about 558khz bit-rate).
Mode3 is Clock =High when inactive (CPOL=1), Data is Valid on Clock Trailing Edge (CPHA=1)
Folowing is how I used the SPI in my design:

Code:

/*
Using SPI 
*/
#include <Arduino>
#include <SPI>
#define SPI_CS0 PA2 // three chip-select lines, but can be more
#define SPI_CS1 PA3
#define SPI_CS2 PA4
#define SPI_CLK PA5
#define SPI_MOSI PA7
#define SPI_MISO PA6

void setup() {
pinMode(SPI_CS0, OUTPUT);
pinMode(SPI_CS1, OUTPUT);
pinMode(SPI_CS2, OUTPUT);
SPI.begin();
//here set your spi freq and mode
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE3));
}

void loop() {

 delay(10);
  // writing to the SPI
  // take the SS (using CS0) pin low to select the chip:
  digitalWrite(SPI_CS0, LOW);
  //  send in the address and value via SPI:
  SPI.transfer(0x3F);//some data to be send
  SPI.transfer(0xAA);
  SPI.transfer(0x55);
  // take the SS pin high to de-select the chip:
  digitalWrite(SPI_CS0, HIGH);//done
 }



_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
MapacheRaper



Joined: Feb 15, 2018
Posts: 166
Location: Spain

PostPosted: Mon May 04, 2020 5:52 pm    Post subject: Reply with quote  Mark this post and the followings unread

This days Im tinkering on the blue pill too. In my case, fisrt I upload the arduino bootloader via the st-link with the 4 pins, the I just use USB like an standard arduino (this way you have to press reset everytime you want to uploade the sketch)

There´s a hackathon of things that I dont know yet so Im reading your notes with a lot of interest, grumble.

Edit: Now reading your drum machine thread... FUCJ YEA
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 2 [26 Posts]
View unread posts
View new posts in the last week
Goto page: 1, 2 Next
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Arduino
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use