0

Nrf52 software-serial does not work properly
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Nrf52 software-serial does not work properly

by jps2000 on Tue Feb 05, 2019 8:28 am

@hathach
It seems that in nrf52832 softwareserial does not perform correctly.
There are always many errors in the transmission (read).
I use just this:
while(ss.available()) Serial.write(ss.read()); // to check what is sent

Even in 9600 baud it is not working without errors.

I use a feather nrf52832 board (bootloader 2.6, SW 9.0.3) and tried to read raw data from a GPS receiver.

When I connect a FT232 then everything is fine.

Also in 9.0.1 it is not working.
I used pins A4 and A5 for RX and TX respectively

Any chance to get softwareserial on nrf52 to operation?
Last edited by jps2000 on Fri Feb 08, 2019 3:01 am, edited 1 time in total.

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by hathach on Thu Feb 14, 2019 6:49 am

Thanks for your patient, I have just came back from Lunar New Year Holiday. Have you tried the gps test example sketch

https://github.com/adafruit/Adafruit_nR ... est_swuart

Last time I tried, it seems to work well. Btw, do you have any other task running e.g i2c, ble in your sketch, if you do please provide your simplest sketch and instruction to reproduce the issue so that we could work and verify the issue is fixed.

hathach
 
Posts: 969
Joined: Tue Apr 23, 2013 1:02 am

Re: Nrf52 software-serial does not work properly

by jps2000 on Thu Feb 14, 2019 7:19 am

Thanks for the response. I thought LNYH might be the reason as I know you for reliable replies.
Yes I am using I2C and BLE.
I now found a GPS module with I2C interface (waiting for boards delayed by LNYH :-) )

In fact I used the same library however on pins A4 and A5.
I2C has rather heavy traffic due to an IMU (BNO080) and a BMP388 talking there
But even without it seemed not to work

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by hathach on Thu Feb 14, 2019 11:59 am

I will do more test with ble traffic later. Due to freeRTOS preemption, ble task will be able to preempt the current code when there is ble traffic, it could corrupt the bit banging of soft serial. We need to insert some mutex guard, fyi, soft serial lib is ported from Arduino primo core, which doesn't have freeRTOS

hathach
 
Posts: 969
Joined: Tue Apr 23, 2013 1:02 am

Re: Nrf52 software-serial does not work properly

by jps2000 on Thu Feb 14, 2019 1:58 pm

Thank you
Sounds plausible. Interestingly there are less corrupted letters in the stream at higher baud rates.
So freeRTOS is likely the crux of the issue.

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by jps2000 on Sat Mar 16, 2019 3:22 pm

Now I gave it another try
software serial 9600 baud

With calling Bluefruit.Advertising.start(0); I get corrupt data like

$GPRMC,001509.870,V,,,⸮⸮r⸮⸮b⸮r⸮⸮b⸮⸮⸮⸮‚bbbr⸮V*3A
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,001509.870,,,,,0,0,,,M,,M,,*4A
$GPGSA,A,1,,,,,,,,,,,,,,,,1*03
$GPGSA,A,1,,⸮⸮bbbbbbbbbbb⸮R⸮⸮j
$GPGSV,1,1,00,0*65
$GLGSV,1,1,00,1*78
$GPGLL,,,,,001509.870,V,N*78

when I comment out Bluefruit.Advertising.start(0); then data are ok:

$GPRMC,000036.868,V,,,,,0.00,0.00,060180,,,N,V*3B
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,000036.868,,,,,0,0,,,M,,M,,*4B
$GPGSA,A,1,,,,,,,,,,,,,,,,1*03
$GPGSA,A,1,,,,,,,,,,,,,,,,2*00
$GPGSV,1,1,00,0*65
$GLGSV,1,1,00,1*78
$GPGLL,,,,,000036.868,V,N*79

So bit banging of soft serial fails in case of BLE traffic

@hathach ---> We need to insert some mutex guard,

please

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by XRAD on Sun Mar 17, 2019 11:20 am

did you try softwareSerial at 38400 b ?

have you tried AltSoftSerial?

XRAD
 
Posts: 348
Joined: Sat Nov 19, 2016 3:28 pm

Re: Nrf52 software-serial does not work properly

by jps2000 on Sun Mar 17, 2019 12:55 pm

not yet
But I do not expect an improvement although I know that faster transmission reduces the probability of errors.
This is a fundamental problem to be solved by experts

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by hathach on Thu Mar 21, 2019 12:50 am

hi jps2000, please be patient for a bit longer, I will give a try later on, still on multiple front now :)

hathach
 
Posts: 969
Joined: Tue Apr 23, 2013 1:02 am

Re: Nrf52 software-serial does not work properly

by jps2000 on Thu Mar 21, 2019 1:08 am

no worry.
I am also crowded with multiple topics. I connected my GPS now via I2C. Com is ok now but still other problems....
Shall I issue something on github?

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by hathach on Thu Mar 21, 2019 1:17 am

yeah, since it is bug, you can file an issue on github. Don't forget to put your simplified sketch and how-to for setup and reproducing the issue as well.

hathach
 
Posts: 969
Joined: Tue Apr 23, 2013 1:02 am

Re: Nrf52 software-serial does not work properly

by jps2000 on Fri Mar 22, 2019 11:56 pm

To close this topic here also: Adafruit has decided not to resolve this bug. So in case of need for a second uart look for uart to spi bridges or i2c

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by hathach on Sun Mar 24, 2019 12:18 am

Thanks for posting it, indeed there is no way to gurantee this, we have no control over SD, it reserves 2 highest irq priority and interrupt at will to maintain ble strict timing connection. If software serial is your only choice, add an layer of crc for data integrity

hathach
 
Posts: 969
Joined: Tue Apr 23, 2013 1:02 am

Re: Nrf52 software-serial does not work properly

by jps2000 on Sun Mar 24, 2019 2:49 am

Does this mean that Arduino primo, by not using freeRTOS, does not comply with BLE spec?

jps2000
 
Posts: 396
Joined: Fri Jun 02, 2017 4:12 pm

Re: Nrf52 software-serial does not work properly

by hathach on Sun Mar 24, 2019 4:25 am

I don't imply such as thing but if primo works for you, you could use it then.

hathach
 
Posts: 969
Joined: Tue Apr 23, 2013 1:02 am

Please be positive and constructive with your questions and comments.