energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
798 stars 671 forks source link

MSP430 micros() accuracy is unusable #1042

Open Schuwi opened 5 years ago

Schuwi commented 5 years ago

Since commit 8eb738e86ae2763ffa242a08f425391986dcd09a the resolution of the micros() function is 512μs on a 16MHz clock (tested). If I understand the code correctly the resolution is even worse at 8MHz clock with 1024μs, so actually coarser than the millis() function. I use the MSP430G2553 to receive RF signals, which is basically impossible to do with this resolution. I reverted the code affecting micros() to the state before the commit in my local Energia installation as a workaround.

TwoRedCells commented 4 years ago

I am confirming that I get 1024μs resolution on MSP430FR2433 @ 8MHz. Workaround is to build your own with a timer. :|

REGIOIGER commented 2 years ago
  • LaunchPad board name and version: MSP-EXP430G2 v1.5
  • Energia IDE version (found in Energia > About Energia menu): v1.8.7E21
  • Board package version (found in Tools > Boards > Boards Manager menu): v1.0.5
  • OS name and version: Windows 10

Since commit 8eb738e the resolution of the micros() function is 512μs on a 16MHz clock (tested). If I understand the code correctly the resolution is even worse at 8MHz clock with 1024μs, so actually coarser than the millis() function. I use the MSP430G2553 to receive RF signals, which is basically impossible to do with this resolution. I reverted the code affecting micros() to the state before the commit in my local Energia installation as a workaround.

Hi Shuwi, Im interested in know how to revert the code affecting micros(), is necessary re-compiling ENERGIA IDE?

Schuwi commented 2 years ago

As this was quite some time ago and apparently I updated the board library in the meantime (or reinstalled my whole system) my local changes were gone. But I did some digging and think I know what I did:

  1. Find where Energia saves the board libraries (those in "Tools -> Board -> Board-Manager..."). For me on linux it's /home/schuwi/.energia15/packages/energia/hardware.
  2. Edit the wiring.c in msp430 (/home/schuwi/.energia15/packages/energia/hardware/msp430/1.0.7/cores/msp430/wiring.c for me).
  3. Revert this change. So that in the end TICKS_PER_WDT_OVERFLOW has the value 512 again, as before the commit in question.

No need to recompile Energia :)

REGIOIGER commented 2 years ago

Thanks a lot Schuwi, I was editing in the wrong place, you helped me a lot :)