STM32F103CT change the length of RXBUFFER of Seiral1

Post here first, or if you can't find a relevant section!
Post Reply
caixf
Posts: 4
Joined: Tue Mar 22, 2022 6:00 am

STM32F103CT change the length of RXBUFFER of Seiral1

Post by caixf »

I am using Arduino IDE to program the STM32F103C8T6. It works. But I can not change the Rx and Tx Buffer size for Seiral1. I know the HardwareSerial.h have the following #defines as:
// NOTE: a "power of 2" buffer size is recommended to dramatically
// optimize all the modulo operations for ring buffers.
#if !defined(SERIAL_TX_BUFFER_SIZE)
#define SERIAL_TX_BUFFER_SIZE 64
#endif
#if !defined(SERIAL_RX_BUFFER_SIZE)
#define SERIAL_RX_BUFFER_SIZE 64
#endif
#if (SERIAL_TX_BUFFER_SIZE>256)
typedef uint16_t tx_buffer_index_t;
#else
typedef uint8_t tx_buffer_index_t;
#endif
#if (SERIAL_RX_BUFFER_SIZE>256)
typedef uint16_t rx_buffer_index_t;
#else
typedef uint8_t rx_buffer_index_t;
#endif
In the program, I using #define to define the Rx_Buffer and Tx_buffer as 256. But when I send the string longs than 64, the content exceed 64 lost.

I am appreciated if somebody could give me advise.

Best regards

Xiaofeng Cai
fpiSTM
Posts: 1944
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 108
Location: Le Mans
Contact:

Re: STM32F103CT change the length of RXBUFFER of Seiral1

Post by fpiSTM »

If you change in the sketch it is not in the scope of the Serial header to redefine it. Sketch is a cpp file.
Use the build_opt.h way as described here:
https://github.com/stm32duino/Arduino_C ... le-content
caixf
Posts: 4
Joined: Tue Mar 22, 2022 6:00 am

Re: STM32F103CT change the length of RXBUFFER of Seiral1

Post by caixf »

Dear fpiSTM

I read the information you mentioned, I use the Arduino IDE to program the MCU. When I put the file build_opt.h under the project sketch, the compile give the error, say no build_opt.h file. I use a AI assistant and save the file at the 'stm32duno'\libraries\STMCore. It works. But the running result is not OK. I send data to Serial1, data less the 64 appeared, exceeded data lost. I am not sure where I made mistake. But anyway, thank you for your help.

Best Regards

Cai Xiaofeng
Post Reply

Return to “General discussion”