Hardware hacking on the STM32L031K6

I’m getting to grips with STM32Cube on PlatformIO (and I’m loving that I can write in C++ for it and get a footprint within a few bytes of a comparable C implementation - I do like the PIC16F’s, but I soon got fed up of writing Pic Assembly)

Anyway, this little Nucleo (L031K6 - that number is indelibly etched in my mind now) is turning out to be a pain in the bottom/bum/butt/ass/derrier (choose your own term). I picked it up on a whim - what better way to learn something than to get lost in it, find the map, do some exploring and come up with something maybe useful.

Thought I could use it to program an EEPROM for another project I’m developing - comes with a virtual serial port, so maybe I can stream what I want to write into the serial port, have this board program up the EEPROM. Easy? Nah. Mbed (Bare-metal) is just a tad large for it and by the time I had a program to interact with the EEPROM, it was in on the edge of 32KB (did I mention that this only has 32K Flash?)

So I’m using STM32Cube and rolling my own interface and learning as I go. It has one 1x USART, 1x LPUART, 1x I2C driver and 1x SPI driver. I switched on one USART to talk to the stlink interface - bingo, got serial communication and happily monitoring stuff - win! Phase 2 - roll out that I2C interface driver. Now my Serial link dropped… wait, what?

I changed the initialization order and it seems to work. But I don’t have high confidence now. Can someone explain what is happening here?

Very difficult to say without the code. Do you have the full code for the working and non-working versions uploaded to e.g. Github?

I’ve checked in my code and you can find it on GitHub: GitHub - majic79/Nucleo_L031K6_I2C_EEPROM at master

Hmmm, It’s working today. I’m wondering if I was working too late last night…

Well then I’ll mark it as solved :sweat_smile:

1 Like