Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
SoftwareSerial not working
2016 年 11 月 07 日
16:26:40
zealot02
New Member
Forum Posts: 7
Member Since:
2016 年 11 月 07 日
Offline

Hello!
I have GPS Receiver connected to pin 42(RX) and 2(TX) as softserial. Also i have L3G4200D gyroskope on i2c bus. When i send i2c command to quickly, my 86dune zero completely crash after time less than a minute and after this GPS data not print in serial.
code:

#include "SoftwareSerial.h"
#include "Wire.h"
#include "i2c.h"

#define TIMER_I2C 100

SoftwareSerial ss(42, 2);

void setup() {
// put your setup code here, to run once:
Wire.begin();
i2c_SetSpeed(0, I2CMODE_AUTO, 400000L);

Serial.begin(115200);
ss.begin(9600);

while (!Serial);

delay(5000);

Serial.println("Init");
}

void loop() {

while (ss.available())
{
char c = ss.read();
Serial.write(c);
}

static unsigned long timer=micros();
if ((micros()-timer)>=TIMER_I2C){
timer=micros();
Wire.beginTransmission(0x68);
Wire.write(0x20);
Wire.write(0xff);
Wire.endTransmission();
}

}

2016 年 11 月 10 日
19:51:31
zealot02
New Member
Forum Posts: 7
Member Since:
2016 年 11 月 07 日
Offline

Change:

Wire.begin();
i2c_SetSpeed(0, I2CMODE_AUTO, 400000L);

on

Wire.begin((uint32_t)400000);

but no effect. Program crash anyway. Who knows why?

2016 年 11 月 14 日
22:31:37
zealot02
New Member
Forum Posts: 7
Member Since:
2016 年 11 月 07 日
Offline

Just a simple program crash in a few minutes when tx pin on gps receiver connected to 42 pin on 86dune zero. Confused

volatile int counter;
void setup() {
delay(5000);
pinMode(42, INPUT_PULLUP);
attachInterrupt(0, gpsinterrupt, FALLING);
counter=0;
Serial.println("Init");
}

void gpsinterrupt(){
counter++;
}

void loop() {
delay(1000);
Serial.println(counter);
}

2016 年 11 月 15 日
18:18:58
zealot02
New Member
Forum Posts: 7
Member Since:
2016 年 11 月 07 日
Offline

When i run sample sketch "SoftwareSerialExample" if i try another bitrate speed (not in my GPS Receiver) сontroller crashed almost immediately Laugh

2016 年 11 月 18 日
15:25:31
zealot02
New Member
Forum Posts: 7
Member Since:
2016 年 11 月 07 日
Offline

Ok, great! I decided the problem with SoftwareSerial!
1. Fixed some bugs in SoftwareSerial.cpp and SoftwareSerial.h with buffer indexes
volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0;
volatile uint8_t SoftwareSerial::_receive_buffer_head = 0;
on
volatile uint32_t SoftwareSerial::_receive_buffer_tail = 0;
volatile uint32_t SoftwareSerial::_receive_buffer_head = 0;
2. in WInterrupts.cpp only one callback on interrupt.
// do user's function
for(; evt > 0; evt--)
PIN86[INTPINSMAP[i]].userfunc();
on
if (evt>0){
PIN86[INTPINSMAP[i]].userfunc();
evt=0;
}
SS working now.
Thank all for the help Wink
UPD
SS proc read(),available(),peek() better wrap in io_DisableINT(); io_RestoreINT();

Forum Timezone: Asia/Taipei

Most Users Ever Online: 229

Currently Online:
3 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Dinosaur: 27

leutenecker: 13

mrZagg: 10

hippy: 9

UIdahoCIT: 8

smeezekitty: 8

Ekkehard: 8

lukeross: 8

tomka: 8

blaxxun: 7

Member Stats:

Guest Posters: 11

Members: 1488

Moderators: 14

Admins: 5

Forum Stats:

Groups: 2

Forums: 11

Topics: 248

Posts: 1114

Newest Members: fungus, MixThors, Shcookius, modtra, alan1974, Sergeyfup, mitunsclusa, Dennissot, bb4000, Ovendaanalolymn

Moderators: Glaux: 70, uaa: 11, guigra: 17, Android_Lin: 228, bcarroll: 12, cucubutter: 84, recycled-air: 12, stevemork: 16, zerozaber: 52, pongraczi: 26, jejump: 14, George Andrews III: 56, poto: 11, garpastym: 20

Administrators: eveshih: 1, anthony: 31, viky6: 0, roboard: 135, hcl: 1