Strange problem with Nano Every resetting itself

Hi,

I've just started to use a Nano Every in a new project with code that was running on a 33 BLE. However, I am encountering an extremely strange problem where the Nano gets into a continuous loop during initialisation where the processor just keeps restarting i.e. resetting itself. I have a lot of code which runs absolutely fine including an external SPI real time clock but the problem occurs when I start trying to use an OLED display using the u8g2lib library for the SSD1309 display. I've narrowed it down to a single line of code in u8g2_setup.c i.e.

u8g2->tile_buf_ptr = buf;

If I comment out this line of code, the problem doesn't happen (but of course the display doesn't work).

I can replace 'buf' with zero or the address of another variable but the code then fails elsewhere.

I am sure that this is something to do with memory as i am using u8g2lib in a fullscreen mode and 'buf' above is a static array of 1024 bytes. However I am not exceeding the Every's memory :

Sketch uses 18700 bytes (38%) of program storage space. Maximum is 49152 bytes.
Global variables use 2168 bytes (35%) of dynamic memory, leaving 3976 bytes for local variables. Maximum is 6144 bytes.

I have no idea how to debug this problem or fix it and cannot see how a single line of code (which seems perfectly innocent to me) can cause the processor to reset. I can only conclude that the hardware itself is at fault (rather than my or library code).

The main problem I had porting my code from the 33BLE to Nano was that 'ints' are 32 bits in 33BLE and 16 bits in Nano. However, I can't see how this might cause this problem as it seems to me that u8g2lib is explicit about the size of integer variables.

I have tried using both ATMEGA328 register emulation and the 'native' ATMEGA4809 modes.

Can anyone help please ?

Moved your topic to it’s current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.

Posting tips.

  • Your OS and version can be valuable information, please include it along with extra security you are using.
  • Always list the version of the IDE you are using and the board version if applicable.
  • How to insert an image into your post. ( Thanks Robin2 )
  • Add your sketch where applicable but please use CODE TAGS ( </> )
  • Add a SCHEMATIC were needed even if it is hand drawn
  • Add working links to any specific hardware as needed (NOT links to similar items)
  • Remember that the people trying to help cannot see your problem so give as much information as you can