Giter Site home page Giter Site logo

stm32-scaler's People

Contributors

v0idv0id avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

stm32-scaler's Issues

Might miss a better result sometimes

Hi, didn't quite understand why you would require the chips frequency to be divisible by the prescaler when there can't be a perfect solution anyways and we have to accept an error. From what I understood a prescaler value of N basically results in the counter being counted ( and reset/triggered on ARR) only every Nth cycle, so what we really are looking for is a good PSC*ARR combination for the desired amount of cycles.
I compared the output of this script with some others and found that for

timescale.py -t 0.007777 -c 22180400 -e 0.1

only when I change the if to

if ( (TIM_BASE_CLOCK % (psc+1) == 0) or (psc==2) ) and x <= TARGET_ARR_MAX[bit]:

I will get a near perfect match of

PSC: 2 ARR: 57498 => FREQ: 128.58426523359827 [Hz] ERROR: 1.6927833490498756e-05 [%] - CRRx[ 50.0 %]: 28749
PSC: 3 ARR: 43123 => FREQ: 128.585010666914 [Hz] ERROR: 0.000562792491631825 [%] - CRRx[ 50.0 %]: 21561

which results in the desired frequncy to only have a tiny bit of error to the clock frequency (357499128.5842870001286 = 22180403.75) whereas the next best only gets near to 22180275 ... probably not relevant in realy life applications but I was wondering if there might be cases where this would miss really much better ones...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.