This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

comprehension question Timer

Hi,

maybe i have a silly question, but i didn't programm timers before. I know how they work. But how is it possible that there are only three Timers in the 51822 and so many parts of the programm part (PWM,BLE,GPIOTE...) which need a timer? How can i organize my timers?

and is it possible to run one timer and write a function like "get_actual_time" which gives me the time in the moment i call the function?

Best reagards, Nils :)

  • Hi Audun,

    Thanks for engaging on this documentation topic, I'm glad you will be passing it on. Given the choice of tutorials in the SDK or a stand alone document, I think a standalone document is better, but once it is written, it could be included in nrf51_sdk.chm as a section, at the same level as the current two top-level topics: Modules and Data Structures.

    In my experience, once a document is called an Application Note, the tendency can be to go for brevity, and focus on specific applications. To set the tone correctly, I would suggest "nRF51 Programmer's Guide".

    The tone of the document is to explain in detail how each part of the chip operates, explain what tradeoffs should be considered where various setting have interactions or where there are dependencies on other parts of the chip, or even system goals such as power consumption, latency, code size, memory usage, etc. I think giving a rationale for the structure and features of each peripheral is also very worthwhile, and mandatory for many of the peripherals.

    A complete set of drivers with a uniform API will probably help, but it will likely rely on a vast number of #define constants , which is probably not much better than the current situation. Lacking the same rationale information, I think it would just let you do things you can already do, but easier. The tough things will still be tough, and people will end up having to look at driver sources to figure out what is going on to then write code for things the drivers don't do or is unclear how to call the driver to do what you want.

    (As an aside, I depend on sources for all library functions. While I understand why source for S110 is not available, I am very concerned about the lack of sources for esb_arm.lib and gzll_arm.lib )

    If I had to choose between a well written "nRF51 Programmer's Guide" and a well written set of drivers, I would choose the Guide. With the right information, I can program my self through pretty much anything. With drivers, there will always be things that aren't covered.

    In terms of resources at Nordic, the better the "nRF51 Programmers Guide" is , the less support questions you get. Of course the same is true of a driver library :-)

  • Thanks again, Philip. Your feedback is appreciated :)

  • Hi Philip,

    thanks for your answer, it works. But i changed the parameters like the preascaler. I messeured with the oscilloscope and when i take a prescaler with (idon#t know the exact value,i have to look on monday) 33 or 34 i get aa perfect millisecond. why don't i get the calculated time?

    best regards Nils

  • Are there any informations for newbies to understand this better?

    best regards Nils

  • The accuracy of the frequency you get from RTC0 or 1 depends on the accuracy of LFCLK. In my example function RTC1_ms_timer.c , I have selected the RC oscillator on line 36. In the reference manual on page 54, LFCLKSRC has 3 possible choices. If you use either the synthesizer, or the 32768 Hz external crystal, you will have accuracy that depends on the crystal, probably around 60 ppm. On page 34 of the product spec, the spec fTOL,RC32k is given as +/- 2% , which is +/- 20000 ppm .

    There is also a calibration process that can use the 16MHz oscillator to temporarily (4 seconds according to fTOL,CAL,RC32k) improve accuracy of the RC oscillator to +/- 250 ppm. I've read the description in the ref manual at 12.1.3 , page 51, the information provided is insufficient for me to figure out how this should be used. I could not find any examples for this part of the chip.

    If you just want an approximate 1 ms tick, then the RC oscillator may be sufficient. If you need a more accurate tick, then use either the synthesizer (which needs the 16MHz crystal) or use the 32768 Hz crystal.

    Also, although you write "a perfect millisecond" , I suspect that it is just close, rather than perfect. Watch the signal on the oscilloscope, as you apply heat (hot air gun) or cold (can of instant freeze) to the chip, and you will see that it is temperature dependent. Probably also dependent on VCC.

Related