Mega (sorry, not Teensy) usage of Timer Three and AltSoftSerial together

Status
Not open for further replies.

DrychronRed

New member
Hi,

This project barely exists as some test code that sends out serial messages, so I'm asking ahead of time before I put more time into this if I'm ok doing what I'm doing.

Here's what I intend to use and why:

Requirements: I need to communicate with four rs-232 devices, controlled from udp/ip over wired ethernet, and I need timeouts on the serial ports. They don't have to be accurate to 1 ms, but I generally need to know when so many seconds are up. I also *would like* to use a serial port for regular debugging.

- Mega 2560: Because it has 4 hardware serial Ports
- W5100 Shield: Because it has Wired Ethernet, and uses SPI - so therefore pins 10, 11, 12, and 13 (I think) on the Mega
- Use Serial for normal uploading and debug printing
- Use Serial1, Serial2, Serial3, and AltSoftSerial on pins 46 and 48 of the Mega to talk to the four devices
- Can't use Timer1 due to AltSoftSerial using the 16 bit Timer 1 (If I understand correctly)
- Using PJRC's Timer3 due to the above 16 bit timer issue. I figure it's better than the stock Timer3, and more likely to work together with Paul's AltSoftSerial.

Questions and comments:

Where am I being stupid?
Note: as long as I can get second accuracy or so I don't care if my timer is 8 bit or 16 bit.
Alternatively I could use Serial, Serial1, Serial2, and Serial3 to communicate with my four devices via the hardware ports and use the AltSoftSerial port as a debugging port if I had to - this has the disadvantage of not being able to use the built-in, while-connected to USB Serial debug stuff, and the advantage that all four devices will get the exact same handling via serial (all using hardware ports) if that's truly useful (may not be worth the effort).
I could use SoftwareSerial instead of AltSoftSerial and transmit out the port only for debug.

I didn't see a Mega (or non-Teensy) forum, so I posted here anyway...sorry.

THANK YOU!
Jeff
 
Just making sure it's clear

I mostly need to know that the TimerThree and AltSoftSerial libraries can co-exist working on the Mega. \

Thank you!
Jeff


Hi,

This project barely exists as some test code that sends out serial messages, so I'm asking ahead of time before I put more time into this if I'm ok doing what I'm doing.

Here's what I intend to use and why:

Requirements: I need to communicate with four rs-232 devices, controlled from udp/ip over wired ethernet, and I need timeouts on the serial ports. They don't have to be accurate to 1 ms, but I generally need to know when so many seconds are up. I also *would like* to use a serial port for regular debugging.

- Mega 2560: Because it has 4 hardware serial Ports
- W5100 Shield: Because it has Wired Ethernet, and uses SPI - so therefore pins 10, 11, 12, and 13 (I think) on the Mega
- Use Serial for normal uploading and debug printing
- Use Serial1, Serial2, Serial3, and AltSoftSerial on pins 46 and 48 of the Mega to talk to the four devices
- Can't use Timer1 due to AltSoftSerial using the 16 bit Timer 1 (If I understand correctly)
- Using PJRC's Timer3 due to the above 16 bit timer issue. I figure it's better than the stock Timer3, and more likely to work together with Paul's AltSoftSerial.

Questions and comments:

Where am I being stupid?
Note: as long as I can get second accuracy or so I don't care if my timer is 8 bit or 16 bit.
Alternatively I could use Serial, Serial1, Serial2, and Serial3 to communicate with my four devices via the hardware ports and use the AltSoftSerial port as a debugging port if I had to - this has the disadvantage of not being able to use the built-in, while-connected to USB Serial debug stuff, and the advantage that all four devices will get the exact same handling via serial (all using hardware ports) if that's truly useful (may not be worth the effort).
I could use SoftwareSerial instead of AltSoftSerial and transmit out the port only for debug.

I didn't see a Mega (or non-Teensy) forum, so I posted here anyway...sorry.

THANK YOU!
Jeff
 
Look for the file known_16bit_timers.h. Maybe you can make TimerThree not conflict by editing those defines.

I also put a similar config file in AltSoftSerial. But most of the other timers on Mega are unusable. You would need to solder wires to the pins Arduino decided not to route.

Again, I can't say for sure if this will work. The most support I can give you for customizing on Arduino Mega is this quick mention of the files to edit, and the pin limitations for AltSoftSerial. If you do get it to work, or learn more, maybe reply here to share that Mega-specific knowledge?
 
Paul et all,

Ok, that's exactly what I needed to hear. In that case, I am going to use TimerOne for the timings I need, and not use AltSoftSerial at all. I will send debug messages out the UDP port and monitor them from a PC program on a certain logical port.

Thank you. Again, that's exactly what I needed to know. I was wrongly thinking that the documentation was saying that only Timer 1 (16 bit) was taken up by AltSoftSerial. I am glad I can spend the time coding the UDP messages and not struggling with getting a fifth serial port to work at all while having proper timeout timings.

Thanks so much for your time!
 
Status
Not open for further replies.
Back
Top