[SOLVED] JNZ stops working
Dear Jeenode experts,
I configured a Jeenode Zero rev.4 to readout a bme280 temperature/humidity/pressure sensor. It continuously reads out the values and sends them over the wireless.
In general it works but stops after a varying amount of time (> 10 minutes). The led is only there to check if the loop is still running.
I hope that someone can give me a hint why it stops. Otherwise it is not realy useful if I have to restart my sensor every 10 minutes.
: readout led-off i2c-init rf-init rf-sleep bme-power lptim-init stop100ms bme-calib begin stop100ms bme-init-sleep stop100ms bme-data bme-calc 6 <pkt +pkt +pkt +pkt pkt>rf rf-sleep led-on stop100ms led-off stop10s key? again ;
RE: JNZ stops working - Added by linuxpeppe 3 months ago
In my experince usually this kind of problem happens when you leave some unwanted stuff in the stack since your function does not consume all parameters.
This is my ugly but working code:
0 constant DEBUG \ 0 = send RF packets, 1 = display on serial port 10 constant RATE \ seconds between readings : .00 ( n -- ) 0 swap 0,5 d+ 0,01 f* 2 f.n ; : show-readings ( vprev vcc tint humi pres temp -- ) hwid hex. ." = " .00 ." °C, " .00 ." hPa, " .00 ." %RH, " . ." °C, " . ." => " . ." mV " ; : send-packet ( vprev vcc tint humi pres temp -- ) 2 <pkt hwid +pkt +pkt 5 0 do +pkt loop pkt>rf ; : low-power-sleep rf-sleep adc-deinit \ only-msi RATE 0 do stop1s loop hsi-on adc-init ; : main 2.1MHz 1000 systick-hz lptim-init i2c-init adc-init 8686 rf.freq ! 42 rf.group ! 62 rf.nodeid ! rf-init 30 rf-power OMODE-PP PA14 io-mode! PA14 ioc! \ set PA14 to "0", acting as ground OMODE-PP PA13 io-mode! PA13 ios! \ set PA13 to "1", acting as +3.3V bme-init drop bme-calib begin led-off adc-vcc ( vprev ) low-power-sleep adc-vcc adc-temp ( vprev vcc tint ) bme-data bme-calc led-on DEBUG if show-readings cr 1 ms else led-on send-packet 30 ms led-off then key? until ;
RE: JNZ stops working - Added by TobiasStockmanns 2 months ago
thank you for your advice.
It was realy some unwanted stuff from the bme-init which filled up the stack.
A drop after bme-init-sleep solved it.