Uploaded by Isha Shah

EC074 WEEK7 REPORTING

advertisement
WEEK 7 REPORT
B. Tech
SEM. VIII
Department of Electronics & Communication
Faculty of Technology
Dharmsinh Desai University
Nadiad-387001
Name:Isha Shah
Batch:F7 EC074
DATE
TASK
24/1/22
I2C on STM32
25/1/22
I2C on STM32
26/1/22
Holiday
27/1/22
SPI on STM32
28/1/22
SPI on STM32
LED BLINKING and NORMAL DEBUGGING:
IDE used here is STM32CUBE
The STM32CubeMX, a graphical software configuration tool that allows generating C
initialization code using graphical wizards
Simple program for checking serial debugging
Fig 1 CubeIDE LED blinking
HAL (Hardware Abstraction Layer or rather Hardware Annotation Library) is a software
subsystem for UNIX-like operating systems providing hardware abstraction.
The STM32Cube Hardware Abstraction Layer (HAL), an STM32 abstraction layer
embedded software ensuring maximised portability across the STM32
microcontroller. The HAL is available for all the hardware peripherals.Using the
STM32 HAL device drivers can be advantageous in so many situations, and help
shorten the development time
LED BLINKING:
Fig 2.ioc file LED blinking
The .ioc file is the data file where Cube holds your project. Later, you can load
it back into Cube, modify your project, and regenerate the code
Using the .ioc file we can change to the specified configuration of GPIOs as
GPIO on board are multiplexed with various configurations.
INTERFACING STM32 WITH I2C SERIAL EERAM:
Below figure shows how we can interface stm32 board with serial EERAM
Fig 3 Interfacing I2C SERIAL RAM WITH STM32F
We use HAL_I2C_Mem_Write to write data at specified address in serial SRAM and
use HAL_I2C_Mem_Read command to read data from specified address from
memory.
HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t
MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t
Timeout)
HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t
MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t
Timeout)
hi2c:Pointer to a I2C_HandleTypeDef structure that contains the configuration
information for the specified I2C.
DevAddress Target device address: The device 7 bits address valuein datasheet must
be shifted to the left before calling the interface MemAddress Internal memory
address
MemAddSize: Size of internal memory address
pData :Pointer to data buffer
Size: Amount of data to be sent
Timeout :Timeout duration
Fig 4 .ioc file for i2c interfacing
From .ioc file we can conclude that PB8 is I2C1_SCL and PB9 is I2C1_SDA
Here EERAM has a 8 bit address 0x50.But as left shifting 1 bit for 7 bit is 0xA0.
Fig 5 main code for i2c memory writing
Here we can observe in the rxdata buffer that the data we wrote at address
0xC0(3<<6) by using the Mem_write function.That means that data is correctly
written and read from EERAM using I2C.
SPI on STM32F NUCLEO BOARD
Fig 6 interfacing SPI with EEPROM
From .ioc file we can conclude that
PA4-SPI1_CS’
PA5-SPI1_SCK
PA6-SPI1_MISO
PA7-SPI1_MOSI
Fig 7 .ioc file for SPI interfacing
Here we used inbuilt function of HAL to communicate via SPI
HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size,
uint32_t Timeout)
HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size,
uint32_t Timeout)
hspi-hspi pointer to a SPI_HandleTypeDef structure that contains the
configuration information for the SPI module.
pData-pointer to data buffer/to receive buffer
Size-amount of data/receive to be sent
Timeout-Timeout duration
Fig 8 main code for spi communication
Output of spi
Fig 9 output of SPI
Download