These are chat archives for SmingHub/Sming

10th
Apr 2016
ChrisRovers
@ChrisRovers
Apr 10 2016 03:21
Trying to do pwm - I can make the sample Basic_HwPWM sample work - it indeed fades an led when flashed on, but as soon as I add
uint8_t pins[8] = { 4, 5, 0, 2, 15, 13, 12, 14 }; // List of pins that you want to connect to pwm
HardwarePWM HW_pwm(pins, 8);
to my own program, it crashes the microcontroller with

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 24940, room 16
tail 12
chksum 0x10
ho 0 tail 12 room 4
load 0x3ffe8000, len 920, room 12
tail 12
chksum 0xba
ho 0 tail 12 room 4
load 0x3ffe83a0, len 4352, room 12
tail 4
chksum 0x63
csum 0x63
{lSFatal exception 0(IllegalInstructionCause):
epc1=0x40240364, epc2=0x00000000, epc3=0x402092d2, excvaddr=0x00000000, depc=0x00000000

Tried not using HardwarePWM but rather using the pwm_init function directly, it crashes exactly the same way (not surprising, since that's what HardwarePWM does in its constructor...)
Is there some setup that I can't find in Basic_HwPWM that I need to do in my app to have things work? I have compared make files, user_config.h, source code, can't see it. Mine is doing more than the basic one is, as far as other stuff - wifi, more serial stuff, spiffs read/write...
Any thoughts?
ChrisRovers
@ChrisRovers
Apr 10 2016 03:42
Sort of guess it is this, from the sdk "PWM APIs can not be called when APIs in hw_timer.c are in use, because they use the same hardware timer. " - something I'm using is also using that timer, maybe?
hmm. if I get rid of my timer start (uiLoopTimer.initializeMs(100, uiLoop).start(); ) it stops crashing like that. But Basic_HwPWM has a timer...
Any ideas?
Patrick Jahns
@patrickjahns
Apr 10 2016 07:34
@ChrisRovers
Use Software Timers instead of Hardware Timers
I have 5 channel pwm running fine on one of my projects
For fading Leds every 20ms a loop is called - haven`t had any issues yet
alonewolfx2
@alonewolfx2
Apr 10 2016 08:01
@elharezmi :) I am using cp2102 serial and its working fine on w10
I tried to change language too but it didn't compile
I will try again
Attila
@elharezmi
Apr 10 2016 08:59
@alonewolfx2 I followed this https://www.youtube.com/watch?v=AEWoeL1hH2I "all" "clean" "flash" work for me. But between 36:00 - 36:01 of this video .what did he make ?I don't know
Attila
@elharezmi
Apr 10 2016 09:07
@alonewolfx2 Please you must pay attention when you try to member of"dialout" group. "sudo usermod -a -G dialout username" if you forget the -a flag.(like me :smile: ) it will begin new adventures :fire:
ChrisRovers
@ChrisRovers
Apr 10 2016 14:56
@patrickjahns Thanks - that's what I thought the issue might have been. Are you suggesting software timers for the PWM? I guess the timer class does have microseconds, which I guess means I can give that a go...
hreintke
@hreintke
Apr 10 2016 15:21
@ChrisRovers :
You should not use software timers for pwm. First of all it has proven to be unstable.
Second, in the SmingRTOS version which will succeed SminfNONOS it will not be available (not present anymore in the espressif sdk).
For PWM you should use HWPWM.
For other application timers you can then use the software timers.
That is also how the basic_hwpwm is structured.
Patrick Jahns
@patrickjahns
Apr 10 2016 15:51
@ChrisRovers
What hreintke suggested - I use HWPWM for PWM and for other timer related things I use the SoftwareTimer class
ChrisRovers
@ChrisRovers
Apr 10 2016 16:10
Ok... that makes sense.. but I don't see how I'm doing timers differently than basic_hwpwm...
They declare their timer as :
v
Timer procTimer;
and call it with :
procTimer.initializeMs(100, doPWM).start();
I declare my timer with :
Timer uiLoopTimer;
and call it with :
uiLoopTimer.initializeMs(100, uiLoop).start();
I see there is a Hardware_Timer, but I don't think I'm using it... maybe something I'm using uses it.. ?
ChrisRovers
@ChrisRovers
Apr 10 2016 16:19
My code is heavily based on the SystemClock_ntp example - basically, I'm talking on Serial, letting the user define ssid, password, tzOffset, optionally saving those values to flash with spiffs, then starting up WifiStation with those values and using NTPClock to talk with an ntp server and setting the system clock
So I am using a fair number of bits and pieces all together and am now looking to add pwm so I can control a couple of servos (I am making an odd clock)
Patrick Jahns
@patrickjahns
Apr 10 2016 17:33
@ChrisRovers
I can only suspect from here on - best guess is to compartmentalize the code and leave fractions out and see when it stops working.
Other than that, if you wish to have a closer look at your issue, it would be good to provide sourcecode
hreintke
@hreintke
Apr 10 2016 18:12
@ChrisRovers :
The functionality that use hwtimer within Sming is only : hw_timer class and servo library.
Hardware_pwm uses hwpwn.
Those have the dependency mentioned in the esp documentation -> use only one of these three in one application.
The Sming "Timer" class is the software timer and can be used together with all above.
But.. beware, the callback from the timer only use very limited processing time, otherwise you will hit the WDT (and delay(..) is using processing time)
Consider making your application more event based, almost all Sming functionality provides callbacks.
Another : If you power your servo's from the same source as your esp, you might get resets when not powerful enough.
Mateusz Zakarczemny
@Matzz
Apr 10 2016 19:47
Hi. Does somebody now how to make eclipse to recognize rboot functions? I'm playing with Basic_rBoot and eclipse editor shows me Function 'rboot_get_current_rom' could not be resolved. Make file works fine. It is not critical but quite anoying
ChrisRovers
@ChrisRovers
Apr 10 2016 20:31
@hreintke @patrickjahns Thanks for the pointers. I'll do that - remove everything except hw_pwm and add back in slowly till I figure out what breaks it.
ChrisRovers
@ChrisRovers
Apr 10 2016 22:28
@hreintke @patrickjahns FYI, it seems to have been the NTPClient - everything else goes back and plays nice, but as soon as I include that in the program, kaboom. Not the end of the world - I can handle NTP myself - the protocol isn't that difficult. Just glad that I still have wifi and spiffs :)
Thanks for your help, both of you