It’s almost final! Which means it’s time to plan about my final project.
We learned about serial communication last week and did some experiments on it. This weekend I experimented with some I2C and SPI on my cheap little microcontroller.
I have to say it’s not easy. It does not have Wire.h like Arduino and there are only a few very low level functions that interfaces with I2C.
HAL_I2C_Master_Transmit(I2C_ADDR, iic->txAddress, &txBuffer, iic->txIndex, I2C_TIMEOUT);
HAL_I2C_Master_Receive(I2C_ADDR, iic->rxAddress, &rxBuffer, iic->rxQuantity, I2C_TIMEOUT);
Code language: C++ (cpp)
Luckily with some code fighting and documentation reading I was able to write a very simple i2c program to dump the first 16 bytes of data from an “ATXBL”(I know, it’s an ATMEL clone) 24C16 EEPROM chip.
Talking about HAL, I finally figured out why my simple GPIO read program was not working. Because some HAL initialisation code turned my desired GPIO pin into something else. To counter this I have to put my GPIO init code right before my main loop.
GPIO_InitTypeDef pinInGPIOConfig;
pinInGPIOConfig.Mode = GPIO_MODE_INPUT;
pinInGPIOConfig.Pin = GPIO_PIN_3;
pinInGPIOConfig.Pull = GPIO_PULLUP;
pinInGPIOConfig.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &pinInGPIOConfig);
Code language: C++ (cpp)
Now onto my final plan. I wanna make something that makes sound again but I am not sure what should I make. Maybe I should talk with Jeff.
Leave a Reply