43oh

# Bernard

Members

68

## Reputation Activity

1.
You don't have to worry about this. The unsigned 32 bit wraps around and the math works properly. Take a look at the code below followed by the results. This is just some straight c code you can compile on your desktop pc and run.

#include <stdio.h> #include <stdint.h> const uint32_t intervalMs = 10000; uint32_t currMs = 0; uint32_t prevMs = 0; void check(check) { uint32_t diff = currMs-prevMs; if ( diff > intervalMs ) { printf("currMs=%u-prevMs=%u diff(%u) > interval=(%u) == %s\n", currMs, prevMs, diff, intervalMs, ((diff) > intervalMs ? "T":"F") ); prevMs += intervalMs; } } void main() { do { check(); currMs++; } while(1); } currMs=10001-prevMs=0 diff(10001) > interval=(10000) == T currMs=20001-prevMs=10000 diff(10001) > interval=(10000) == T ... many lines later near the wrap ... currMs=4294960001-prevMs=4294950000 diff(10001) > interval=(10000) == T ... and the first value after currMs wraps around .. currMs=2705-prevMs=4294960000 diff(10001) > interval=(10000) == T currMs=12705-prevMs=2704 diff(10001) > interval=(10000) == T ... and on it goes .. 2705-4294960000=10001 when they are both unsigned 32 bit integers.

The real bug is using a long instead of an unsigned long for the value previousMillis and interval.

I just checked over at the arduino github and it looks like someone fixed it here:

https://github.com/arduino/Arduino/commit/83ef1814cfda808f94cd80a70d7cee8725e24a13

[/edit]

-rick
2. Bernard got a reaction from spirilis in Energia bug in Blink without delay tutorial
Hi,

May be this help : http://playground.arduino.cc/Code/TimingRollover

Salutations
3.
look at this:
https://github.com/energia/Energia/commit/aa5509e8ab146d715e3b0369c755b1a2ef0dcc14
https://github.com/energia/Energia/issues/464

simply remove
4. Bernard got a reaction from Smakkemeken in Say Hi for a Giveaway entry.
Hi
5.
LOL oh my! Weird, is the TM4C129 bpak headers just not supplying enough?
6. Bernard got a reaction from Rickta59 in TM4C129 nRF24L01 RX working example
Hi,

Here is a working example TM4C129 using Enrf24 library

Salutations

Bernard
7. Bernard got a reaction from Rickta59 in TM4C129 nRF24L01 RX working example
Hi again,

I forgot to post the TX side :
I have spent many time to add  the Ethernet part in the loop and so far no success ... any help would be appreciate
Salutations
Bernard
8. Bernard got a reaction from energia in TM4C129 nRF24L01 RX working example
Hi,

Here is a working example TM4C129 using Enrf24 library

Salutations

Bernard
9. Bernard got a reaction from spirilis in TM4C129 nRF24L01 RX working example
Hi,

Here is a working example TM4C129 using Enrf24 library

Salutations

Bernard
10. Bernard got a reaction from Duloxetinepka in Say Hi for a Giveaway entry.
Hi
11. Bernard reacted to energia in My first attempt TM4C129
The Sketch below (Example->Ethernet->EthernetWebserver) should work as expected. The only difference that I see is that "EthernetClient client;" is outside of loop ()rather than inside loop(). I will give you Sketch above a try later today to see if I can reproduce the issue.
12. Bernard reacted to spirilis in Simple IRC example
Ok this is just silly, but I had to do it.

Simple IRC client that pops into #energia, says hi and runs.
14:17 -!- SpirTivaLP [~SpirTivaL@<hostname_redacted>] has joined #energia 14:17 < SpirTivaLP> Hi everyone! I am a TI TM4C129 LaunchPad connecting to IRC and sending you a brief message. Currently using Energia release 12. 14:17 -!- SpirTivaLP [~SpirTivaL@<hostname_redacted>] has quit [Client Quit] We'll call it the beginnings of a Tiva-C IRC bot...
13. Bernard reacted to chicken in MSP430G2553 and Rotary encoder
Serial print can be very slow and should be avoided inside an interrupt routine.

Better to write the state/result into a global variable (declared with the "volatile" prefix) and process it in the main loop. You might need to add some additional logic to detect whether the encoder is still moving, e.g. by setting a flag in interrupt routine and resetting it in the main loop.
14. Bernard got a reaction from aduckysoods in How to come back to IP.Board
Hello,

days ago I switched to IP.Board mobile ( just curious) and I cannot come back to Ip.Board. I haven't found how to do that. some help needed.

Thank you

Bernard
15.
Are we voting for this round of POTM soon?

Time to reveal my Easter Egg "game" for upvotes.

Source code now host on github. https://github.com/simpleavr/mclock
16. Bernard got a reaction from spirilis in dtostrf in Energia
Hello,

I finally got sprintf working. I am able to send and receive datas from BMP085

here is my working code:

Thank you all who helped me.

Salutations
17. Bernard reacted to spirilis in dtostrf in Energia
Huh, doing a quick google search, apparently dtostrf is a unique function that only comes with the AVR libc. Energia probably doesn't support it but it doesn't sound hard to emulate.
18. Bernard reacted to energia in dtostrf in Energia
I have not looked at it in detail but it seems that sprintf() for floats is broken in Arduino/AVR. It seems that dtostrf() was implemented to offered as an alternative.
The details are here: http://dereenigne.org/arduino/arduino-float-to-string

On Stellaris sprintf() for floats is fully functional and you should use this to convert floats to strings.
// Allocate enough to store PI with with 4 decimals. char str[5]; void setup() { Serial.begin(115200); Serial.print("PI in a string: "); // Print PI to a string with 4 decimals sprintf(str, "%.4f", PI); // Print the string to the serial terminal Serial.println(str); } void loop() { // Nothing to do here }
19. Bernard got a reaction from Smakkemeken in How to come back to IP.Board
Hi,
Thank you very much Bluehash .. it is ok
20. Bernard got a reaction from Smakkemeken in How to come back to IP.Board
Hello,

days ago I switched to IP.Board mobile ( just curious) and I cannot come back to Ip.Board. I haven't found how to do that. some help needed.

Thank you

Bernard
21. Bernard got a reaction from sirri in Reading LM4F120 internal temp sensor
Hello,

Here is a ino file that allow to display temperature  from LM4F120 internal sensor.

It is based on example from TI workbook , ported a la mode Energia.

Nothing spectacular. I am slowly learning ARM and I wanted to share.

Bernard

22. Bernard got a reaction from pedroarbs in Timer interrupt on LM4F120 using TimerIntRegister issue
Hi,

Thanks to patolin my problem is solved
23. Bernard got a reaction from jcR in attachInterrupt on Stellaris Launchpad
Hello JCR,

Contrary to arduino documentation on Stellaris you can use all  GPIO pins as first argument of the "attachinterrupt function"

ex:
attachInterrupt (PB_3, isrFunction, mode); Here is an example using PUSH1  on PF_4 that toggle RED_LED

/* Test interruption et antirebond */ unsigned long DebounceTime; unsigned long LastDebounceTime = 0; volatile int FlagStateRedLed = LOW; volatile int FlagStateGreenLed = LOW; void setup() { Serial.begin(9600); pinMode(RED_LED, OUTPUT); pinMode(PUSH1, INPUT_PULLUP); attachInterrupt(PUSH1, ChangeStateRedLed, FALLING); } void loop() { for (int i = 0; i < 100; i++) { Serial.println(" Waiting for push1 pressed"); delay(10); } } void ChangeStateRedLed() { DebounceTime = millis(); if ( DebounceTime - LastDebounceTime > 200 || DebounceTime < LastDebounceTime) { FlagStateRedLed = !FlagStateRedLed; digitalWrite(RED_LED, FlagStateRedLed); LastDebounceTime = DebounceTime; } } Hope this help

Cheers

Bernard
24. Bernard reacted to bluehash in How to come back to IP.Board
I need to switch you manually because of a bug... hold on.

Edit: Check now. If not.. PM me.
25. Bernard got a reaction from trungkiena6 in Help me about TIMER
Hi Trungkiena6,

It includes a nice tutorial for interrupts and the timers.

Cheers

Bernard

×
• Blog

• #### Activity

×
• Create New...