Go Down

Topic: NewSoftSerial Library: An AFSoftSerial update (Read 19591 times) previous topic - next topic

arnewbie

Hello Mikal,

would it be hard to change NSS library work with inverted serial signals?


mikalhart

Hi arnewbie,

I don't have time to do it, but I wouldn't imagine that it would be too hard.  Make sure you have an external pull-DOWN resistor for the RX line, and then simply invert all the digitalRead and digitalWrite calls.  Leave out the digitalWrite call that triggers the internal pull-up resistor for RX.  I would think that would probably do it.

Mikal

arnewbie

Hello,

Does interrupt function get called for both HIGH and LOW or would I need to change the way interrupts are triggerred?
My Garmin GPS module has inverted TTL levels and I used modified simple serial to get the data, but I like your code much better and I plan to use it with TinyGPS.

mikalhart

Quote
Does interrupt function get called for both HIGH and LOW?


Yes.  The "PC" in PCINT0_vect stands for "Pin Change".  Note that almost the very first thing that happens in recv() is that a test is done to exclude an interrupt generated on a pin changing to the "wrong" state.

Mikal

Jin

How is it that the Windows version of the compiler doesn't have the register problem? I thought they were both on the same version and based on the same code, no?

arnewbie

Thanks Mikal,
I changed all the HIGH to LOW and LOW to HIGH as you suggested and inverted a couple IFs and it works with TinyGPS like a dream.

The only problem is it seems to interfere with mem's ServoTimer2. I can practically see when GPS sentences are being send in the way servo moves :). ServoDecode uses pin 8 to read PPM from receiver. With ServoTimer2 i used pins 234 and 7. GPS through NewSoftwareSerial is connected to pins 5 and 6 at 4800 bods. Is this due to limitation on arduino processing power or is there something can be done with maybe assigning different interrupt handlers to servos and GSP serial? I guess using built in UART on pins 0 and 1 for GPS is going to be my last resort... :)

mem

That combination is asking the Arduino to do an awful lot of time critical stuff in interrupt handlers that are being called very frequently. I don't think the pin assignments matter. Using the hardware serial should solve the problem if that option is open.

Jin

The soft serial interrupt will run (and exit quickly) any time any of the pins in the same block change. You might try putting all the servo pins on a different port if you can rewire it and see if that helps. If you need the PWM pins, try putting the serial on one of the analog pins.

pracas

I've been trying to use the New Soft Serial and get the following error....
Code: [Select]
NewSoftSerial.cpp:165: warning: 'PCINT0_vect' appears to be a misspelled signal handler
NewSoftSerial.cpp:170: warning: 'PCINT1_vect' appears to be a misspelled signal handler
NewSoftSerial.cpp:175: warning: 'PCINT2_vect' appears to be a misspelled signal handler
NewSoftSerial.cpp: In member function 'void NewSoftSerial::begin(long int)':
NewSoftSerial.cpp:250: error: 'PCICR' was not declared in this scope
NewSoftSerial.cpp:251: error: 'PCMSK2' was not declared in this scope
NewSoftSerial.cpp:254: error: 'PCICR' was not declared in this scope
NewSoftSerial.cpp:255: error: 'PCMSK0' was not declared in this scope
NewSoftSerial.cpp:258: error: 'PCICR' was not declared in this scope
NewSoftSerial.cpp:259: error: 'PCMSK1' was not declared in this scope


What does this mean? how do i resolve this?
Be The Change...

mikalhart

What compiler/Arduino version are you using?  That should work fine with Arduino 13 and avr-gcc 4.3.2.

Mikal

pracas

Mikal,
I use Arduino12 not sure of avr gcc version though.. how do i check it?

cheers,
Pracas
Be The Change...

mikalhart

The binary is in hardware/tools/avr/bin.  If you run

avr-gcc -v

it tells you the version number.  If you are in Windows, I think this is guaranteed to be 4.3.0 by default.  But you're not, are you?

Mikal

pracas

yes i'm on windows.... xp sp2... and yes it is version.. 4.3.0 Should i Upgrade or something? this means a lot to me! :(
Be The Change...

mikalhart

pracas, the only thing I can think is that your installation is hosed up somehow.  I can compile NewSoftSerial fine in 0012 under XP.  Wait a sec.  What *board* are you compiling for?

M

pracas

Be The Change...

Go Up