Here is the pattern I have been trying to generate for a 8×8 matrix display such that each led being lit represents a particular count:
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000
10000001
10000010
10000100
10001000
10010000
10100000
11000000
11000001 and so on….. until all the bits become 1.
I was able to shift the the bits from right to left, such that 0x01
becomes 0x80
, but how do I hold the MSB in its place and start shifting a new bit from LSB(from right side) as described above?
void MAX7219_SendData(uint8_t address, uint8_t data) {
uint8_t txData[2] = {address, data};
MAX7219_CS_Low();
HAL_SPI_Transmit(&MAX7219_SPI_INSTANCE, txData, 2, HAL_MAX_DELAY);
MAX7219_CS_High();
}
I use the above function to talk MAX7219 IC via SPI.