-
Hello,
I try to connect a radio module using an SPI link (on SPI3, Espruino Pico, Firmware V1.90)
Here is my code :SPI3.setup({sck:B3, miso:B4, mosi:B5, baud:10000, mode:0, order:'msb'}); var registreW = {data : 0x81, count : 1}; var modeASK = {data : 0x23, count : 1}; var returnedData; returnedData = SPI3.send(registreW,A7); console.log(returnedData[0]); returnedData = SPI3.send(modeASK,A7); console.log(returnedData[0]);
NSS Pin is A7.
Since this code doesn't work (communication doesn't work), I had a look at signals with the logic state analyzer.
I attach a screen capture. In fact, NSS PIN is set high too early, when the last byte is not totally sent. I looked at the code line 212, the PIN change seems to be executed without knowledge of end of transmission, but I can be wrong !!
Help will be greatly appreciated.
Best regards
GeekBot -
I did some more measurements.
Battery voltage 2.78V
3.3 V output : 2.5V
LED1 turned on, Espruino running.
I confirm that the transistor has just some mV of voltage drop.
Since, I estimate the current over 35 mA, I have to look at the regulator datasheet to see if it is an expected value.
Anyway, I manage with these figures!
GeekBot -
@Gordon, thank you, I will do accurate measurements and reporting tomorrow. I come back to you.
Best regards
GeekBot -
-
@Gordon, eventually I have a doubt; the 'Bat' pin you talk about is the 'VBat' pin (PIN2 of J2 on Pico, called 5V on the schematic) ?
Because there is also the VBAT on the schematic which is the PIN 1 on J1, and called BAT_IN on the Pico coloured diagram on the web site.
According to our discussion, I guess the 'Bat' is the 5V on the schematics, but I need to be absolutely sure.
Thanks a lot
GeekBot -
-
@allObjects, thank you for these detailed explanations, I understand how it works.
However, I am still turning around my problem. I believe my code follows to what is explained above.
Test 1: I plug Espruino, download the code and type onInit() : it works.
Test 2: I plug Espruino, download the code, save(), unplug replug : doesn't start correctly
Test 3: I plug Espruino, download the code, save(), unplug replug : doesn't start correctly, in the IDE click on top left icon to reconnect the IDE to Espruino, magically it starts to work correctly.What happens when I click on the connection icon in the IDE?
Thanks again
GeekBot -
Hello Experts,
I read the thread you mentioned above, and I am trying to turn its content into a set of design and understanding statements. Could you tell me if I correctly understand the way it works? I hope I won’t confuse others with silly ideas...
These statements ensure that after doing a save() of the software, unplugging the Espruino to un-power it, re-powering it, the software will startup and reach a deterministic state at the end of the onInit() execution.
1 - Global constants are declared as var XXX= xxx. At re-power up, they will be reloaded from flash with their value as they were initialized the first time when the software has been downloaded from the IDE and subsequently executed from top down to bottom.
2 - Global variables are initialized the first time the program is downloaded to Espruino from the IDE (as said in 1). On save(), their current value is saved in flash. At power up, global variables are reset with the values stored in flash (due to the last save()). So, if they have been changed by program execution and not re-saved, their current value is lost and replaced by the flash previously saved value.
3 - On save() execution, function declaration and global code are saved in the flash memory. An instantiated module like ‘var modulevar = require(xxx)’ is saved and is recovered with full instantiation and capability at re-power up (like any other global variable previously saved) .
4 - At powerup, the following operations take place (in order) :
a/ Global variables and code is downloaded from flash memory to ram. There is no execution from top to bottom of the code. So initialization done in the global context is never replayed after the first IDE download and execution.
b/ onInit() function is invoked
c/ when onInit() ends, the system goes to 'Idle' if no event is present in the JavaScript queue (We define 'Idle' as a state where no event is present in the event queue and any processing triggered by previous events is terminated).
5 - onInit() must ensure that at its end, all variables are in the required state.
6 - As consequence of 5, onInit() function must take care of changing global variables to desired values if the saved values are no longer relevant.
7 - onInit() is executed in a time period (init must not last forever! ) and must ensure consistency inside its own execution scope. Javascript is event oriented and not sequence oriented. It means that programmer is responsible for dependencies during asynchronous execution. Two patterns are available to ensure sequential execution (and therefore ensure dependencies constraints):
a/nesting callbacks that will execute in order - called when previous conditions are met-,
or,
b/place initialization statements in time order using timeout function which call initialization functions in order of increasing timeout values.May be there are other ideas I have not reported.
I think my code follow these rules, but it doesn't work! (yet).
Thanks a lot for your help.
GeekBot
-
-
Hello,
My program works like a charm when I click on the download button and type onInit().
If I download and type save(), the program is copied to the flash memory (no error, everything ok (apparently)).
But it doesn't execute the same. Symptoms are linked to timing, for instance I get timeout on AT commands.
What can be different between IDE (ram) execution and flash execution ?
Any clue ?
Thanks a lot
GeekBot -
-
Looking at the datasheet, it seems possible. However, a resistor bridge at the output will probably consume some current. No idea how much.
I hesitate to do a try... -
-
Hello
I want to power my Espruino Pico with a Lithium battery CR 2450 (3V and probably down to 2.5 V). I read the doc on powering, and I see that Vbat should be > 3.6 V.
Is it possible to power Pico with a 3V Lithium battery ?
On which Espruino pin shall I connect the + of the battery ?
Thanks a lot
GeekBot -
Hello,
I needed a logger for my Espruino projects, so I wrote one. I decided to make a module of it and to release it to the community.
The address is : https://github.com/ArnoldFranz/minilog4js
If you think that this logger can join the Espruino modules, I will prepare the documentation.
Any advice and suggestion is welcome.
Best regards
GeekBot -
@DrAzzy. Since the RN2483 breakout board is designed to perfectly fit the Espruino Pico, I take the freedom to ask a question about this board on this forum. So, I am doing a prototype with Pico and the breakout board. I am designing the antenna. To optimize the antenna I need to know if there one layer dedicated to a ground plane? If yes, which layer is it ?
Thanks a lot for this great breakout board.
GeekBot -
Thanks again., @allObjects, Yes Great product and great service.
-
-
Hello,
I have received my brand new Espruino Wifi, and started testing it. In fact it is not recognised on the USB.
Plugin it in the USB port of my linux box and issuinglsusb
does show that the device is not detected. I have several USB cables which work with other devices, and I tested them without success. Same story on Windows 10.
Another symptom is: when plugin the USB while pressing the button, the red and green LEDs turn on together but they don't pulse, they just stay on.
I looked at the troubleshooting page, I conclude from this page that I should reflash (but it is not feasible through USB).
Can you advice me how to make it working?
Thanks a lot
GeekBot -
-
@DrAzzy, I discovered the problem looking at signals with my oscilloscope, I am quite sure that my code didn't pull down the line before, but a mistake on my side is always possible... I confess that I am a bug maker... However, if GPIOs are in high impedance state at reset, the oscilloscope can pull the line down by itself since it has a 1 M input impedance only. Anyway, the module was stuck in the break condition. I like the idea of putting a pullup, I will test it. However, when power goes on, I always fear a glitch on the GPIO that could leave the module in the deadlock. Do you think that when power goes up, that GPIO will remain in high impedance? No glitch? I have to look at the ST datasheet...
-
The problem I had is relative to power up and reset of both Espruino and RN2483. When the Espruino boots, rx and tx lines are set as GPIO and tired down to 0. The RN2483 sees this as a break condition and waits indefinitely for the 0x55 character. You can't escape this state. The only way is to make a hard reset on the module while tx (of Espruino) is set to 1. So the right sequence is:
1/ Power up the system (Espruino and RN2483)
2/ Set Serial configuration (this make the Serial GPIO tx @ 1)
3/ Wait a few hundreds of ms
4/ Do a hard reset of the RN module using one Espruino GPIO line (keeping tx espruino at 1)
5/ Wait 400 ms or catch RN reset message
6/ Go ahead, the system is ready.
HTH
GeekBot -
@allObjects and @Gordon, thank you very very much for your detailed explanations. They help me a lot in my JavaScript education. Now I understand the code and the way to use it properly.
Best regards
GeekBot -
Sorry, I understand that you can't understand what I am talking about!
The code is the example presented here: http://www.espruino.com/AT
The part AT.cmd...
Thanks
GeekBot
I use a Saleae logic analyzer. You can purchase one on their website.
It works great.
GeekBot