Reply to topic  [ 14 posts ]  Go to page Previous  1, 2
STM8S103F3 Development Board (HCDVBD0034) 
Author Message

Joined: Sat May 13, 2017 12:43 pm
Posts: 16
Post Re: STM8S103F3 Development Board (HCDVBD0034)
Now it's just a small step to playing a tune in the background:

* a words to represent musical notes
* maybe some kind of ADSR simulation using the PWM duty cycle
* some kind of action table
* a background task that interprets the action table

Actions can also be percussion elements, e.g. an annoy beep from the buzzer output. In Forth anything goes!


Sat Jul 08, 2017 8:07 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 34
Post Re: STM8S103F3 Development Board (HCDVBD0034)
Any ideas on calibrating TIM1 to give more accurate frequencies? 32kHz = 31.75


Sat Sep 16, 2017 5:26 pm
Profile

Joined: Sat May 13, 2017 12:43 pm
Posts: 16
Post Re: STM8S103F3 Development Board (HCDVBD0034)
31.75kHz is within 0.8% of 32kHz. Application note AN2822 describes calibration procedures for the internal oscillator. The calibration steps are 1%: in your case decreasing CLK_HSITRIMR by one would reduce the error to 0.2%. If your application needs better accuracy you either need a reference frequency, or a crystal.


Tue Sep 19, 2017 7:08 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 34
Post Re: STM8S103F3 Development Board (HCDVBD0034)
Cool, I will try that. I do have perfect pitch so it should be more tolerable.
Trimming the clock does now seem to work on another chip. :shock:

This file is loaded in picocom with ctrl-A ctrl-S ~/Desktop/Forth/HSI.f

\ contents of HSI.f
\ 1st try trim freq and confirm register readback at 16 kHz

FILE
NVM
: CLK_HSITRIMR $50CC ;
: f3 3 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.45 lowest freq
: f2 2 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.52
: f1 1 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.70
: f0 0 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.87 kHz reset value
: f7 7 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.05
: f6 6 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.24
: f5 5 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.43
: f4 4 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.62 highest freq
: cc $50C0 $F dump ;
RAM
HAND
initTIM1
16000 Hz
f3 <enter> 3 ok

Three-bit two's-complement integers
Bits, Unsigned value, Two's complement value

011 3  3 
010 2  2 
001 1  1 
000 0  0 
111 7  −1 
110 6  −2 
101 5  −3 
100 4  −4 

https://en.wikipedia.org/wiki/Two%27s_complement


Tue Sep 19, 2017 11:44 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD