reduced RAM serial library for Teensy LC?

Status
Not open for further replies.
Does a library exist that replaces that existing Arduino Serial library that uses less RAM? All I need to be able to do is read/put characters into UART from the UART buffer, and that takes up 2K of my precious RAM on the teensy.
 
The Teensy LC has 3 hardware UARTs on chip which are supported by the core libraries. Thus, there is no need to include the Arduino Serial library which AFAIR uses memory and CPU cycles consuming bit banging via GPIO.
 
Try setting Tools > USB Type to No USB. Click Verify to see the memory difference by only removing the USB code.

If you upload a sketch without USB support, of course Arduino can't send a USB request for it to automatically reboot. So next time you upload, expect to see the message that it couldn't auto-reset and you need to press the button on your Teensy.
 
Hm, @PaulStoffregen, the problem is that I still need to be able to communicate via serial to the PC. I suppose I could work around it by having an Arduino relay serial data, but that sounds a bit silly.
 
Sometimes, the most efficient way is to use the next better hardware..i.e. a Teensy 3.2 :)
A single day fiddling if you are low on ram costs you more than a Teensy 3.2
 
If you are trying to save Ram, you could go into the arduino core3 files and edit the files, Serial1.c Serial2.c and Serial3.c and reduce the buffer sizes. You will See some defines at the top of these, and for example Serial1 defaults to 64 and 64 bytes. So you could make these a bit smaller... Again don't know what else your program is doing, so could maybe look for I2C buffers and the like as well
 
Yes, it's a possibility to get a bigger chip - that's the plan eventually, the LC is just too small for what I want to do, unfortunately. I need about 1KB more RAM, so changing buffer sizes probably won't cut it. I think I'll develop as much as I can on the LC, then move on up.
 
Reducing the number of buffers from 12 to 4 gave me an extra 512 KB or so, and that's great. But what am I losing? What is the benefit of having more buffers? I did try it with 2 buffers and it didn't seem to want to transmit anything or receive, although I may have done something wrong.
 
Status
Not open for further replies.
Back
Top