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 seem to work but is inconsistent with 3 identical frequencies?

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

FILE
NVM
: CLK_HSITRIMR $50CC ;
: f0 0 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.04 kHz
: f1 1 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 3.999
: f2 2 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 3.999 ?
: f3 3 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 3.999 ?
: f4 4 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.229
: f5 5 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.18
: f6 6 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.123
: f7 7 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.087
RAM
HAND

initTIM1
4000 Hz
f0 0 ok


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