I'm doing to project where I would like to be able to transmit SENT messages:https://www.renesas.com/us/en/document/whp/tutorial-digital-sent-interface-zssc416xzssc417x#:~:text=The%20basic%20unit%20of%20time%20for%20SENT%20is,starts%20a%20message%20frame%20and%20provides%20a%20method.
My first thought was to use the digitalpulse method but I then realized that the longest unit of time "tick" can be 90uS. the timeing may require using low level programming. I'm looking for a place to start, I can write my own module but perhaps there is a module that I can start with. I'm just looking for any advice on how to best tackle wtih issue.
thank you in advance.
What Espruino device would you be using to send the data?
Personally, I'd say it's best to use a peripheral that can stream out data bits in one long chunk rather than relying on bit-bashing - so most likely SPI (or on nRF52 we use the I2S peripheral for neopixels).
So then you just build up a bit stream in an array and send that array to Espruino to send.
On nRF52 that may be slightly more problematic (I'm not sure we can guarantee SPI doesn't have pauses), but if that is an issue, I could expose the code that's used for neopixels, because under the hood that's exactly what we do there on all platforms - just stream out a long string of bits without any gaps.
I would really like to try it on the nRF52, i can verify with an ocsilloscope , if anything it will be a learning experiance.
Ok - I just had a quick play with this code on nRF52:
var data = new Uint8Array(100);
That outputs a stream of bits, just 1/0/1/0/etc at 1MHz - and it seems pretty stable and reliable, even with Bluetooth running at the same time.
So I think that should be fine, so I think 'all' you'll need to do is work out what bits you need to send.
I'd say maybe the easiest way to do it is to write it all out as a string of digits:
Then you can add to it bit by bit, and can also print it to help you debug.
Then when you're ready you can convert it to an array with something like:
data = new Uint8Array(s.length>>3);
for (var i=0;i<data.length;i++) data[i]=parseInt(s.substr(i*8,8),2);
thanks for your help! I will play around with this method and write some code to produce the correct strings of bits. I'll do some testing with a sent decoder. If I find that it works well, I can try to write something up, perhaps others will find this useful.
Thanks! And yes, absolutely! Maybe it could be made into a module that I can host on the Espruino website?
I would be happy to contribute to the espruino community!
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem