Comments (2)
I believe that the following code should be correct
// get dividers from requested baud rate
uint32_t aux=F_CPU;
uint32_t ii=0,jj=1;
uint32_t baudrate=kbaudrate*1000;
while(aux/(16*(1<<ii))>baudrate) ii++;
while(aux/(jj*(1<<ii))>baudrate) jj++;
uint32_t minpresc=ii;
uint32_t mindiv=jj-1;
m_sdhc_baudrate=F_CPU/((1<<minpresc) * (mindiv+1));
// Change dividers
sysctl = SDHC_SYSCTL &
(~ (SDHC_SYSCTL_DTOCV_MASK | SDHC_SYSCTL_SDCLKFS_MASK | SDHC_SYSCTL_DVS_MASK));
SDHC_SYSCTL = sysctl |
(SDHC_SYSCTL_DTOCV(0x0E) | SDHC_SYSCTL_SDCLKFS(minpresc) | SDHC_SYSCTL_DVS(mindiv));
presc is a single bit and div is a number
This includes the (untested case) that presc = 0 is valid input and that presc=0 does not prevent div to be effective.
The way I calculate is if F_CPU=96 Mhz and baudrate is 3 kHz then ii=1 and jj=16
presc=1 and div = 15 and therefore 96MHz/((1<<presc)*(div+1)) = 3kHz
Can you agree?
from usdfs.
from usdfs.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from usdfs.