8000 Changing the buffer size for I2C in twi.h without editing the MiniCore library · Issue #351 · MCUdude/MiniCore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Changing the buffer size for I2C in twi.h without editing the MiniCore library #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
robertrau opened this issue May 21, 2025 · 1 comment

Comments

@robertrau
Copy link

First, I am very happy with MiniCore for the ATMEGA328PB. Development has been problem free and fast on my Macbook M4.

I wrote a small driver for a ST M24M02E 2Mb EEPROM. The device has a 256 write buffer as many EEPROM have. My application uses 32 byte records that we read and write. With the two bytes of address required for each transaction I can only write 30 data bytes per EEPROM write operation. Reviewing the code I found twi.h surrounded the define with an 'if not defined':
#ifndef TWI_BUFFER_SIZE
#define TWI_BUFFER_SIZE 32
#endif
I thought I could just define a size of 34 at the top of my sketch but then found that the IDE pre-compiles all the libraries before my sketch, making the 'if not defined' useless.
Am I doing this wrong? Is there a way to override the 32 byte default without editing your library?

@MCUdude
Copy link
Owner
MCUdude commented May 21, 2025

The i2c/twi library is compiled before the user program, so that's why you're stuck with 32 bytes. I'll recommend using PlatformIO instead. There you can specify compiler flags and fix this by adding -DTWI_BUFFER_SIZE=256.

See the PlatformIO README for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0