how to assign bit values at once to different port pins of different I/O port through a register which I define as comprised of those port pins of I/O ports?
I want to define a variable(name=my_reg) of uint8_t type which i plan to use it as a register of 8 bits. Each bit of this register should send its value to different bits of different I/O ports.
For example When my_reg = 3;
LATAbits.LATA0 which is my_reg.0 should be 1
LATAbits.LATA1 which is my_reg.1 should be 1
LATCbits.LATC0 which is my_reg.2 should be 0
LATCbits.LATC4 which is my_reg.3 should be 0
LATBbits.LATB5 which is my_reg.4 should be 0
LATBbits.LATB0 which is my_reg.5 should be 0
LATAbits.LATA7 which is my_reg.6 should be 0
LATAbits.LATA6 which is my_reg.7 should be 0
I am new to C. I defined a struct which is comprised of 8 subplaces all is 1 bit. But i couldn't give a value to MY_REG.
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
| typedef struct {
uint8_t L1;
uint8_t L2;
uint8_t L3;
uint8_t L4;
uint8_t L5;
uint8_t L6;
uint8_t L7;
uint8_t L8;
} MY_REG; |