Je cherche à additionner deux octets pour allumer en même temps les 2 premières led de mon MCP23S17.
Code : Tout sélectionner
// Port Expander module connections
sbit SPExpanderRST at RC0_bit;
sbit SPExpanderCS at RC6_bit;
sbit SPExpanderRST_Direction at TRISC0_bit;
sbit SPExpanderCS_Direction at TRISC6_bit;
// End Port Expander module connections
bit oldstate; // Old state flag d'un bouton
unsigned char i = 0;
char A = 0b00000001;
char B = 0b00000010;
char G;
void main() {
PORTB = 0; // All PORTB pins are cleared
//TRISB = 0b11111111; // All PORTB pins are configured as outputs
TRISB0_bit = 1; // set RB0 pin as input
TRISB1_bit = 1; // set RB1 pin as input
TRISB2_bit = 1; // set RB2 pin as input
TRISB3_bit = 1; // set RB3 pin as input
TRISB4_bit = 1; // set RB4 pin as input
TRISB5_bit = 1; // set RB5 pin as input
TRISB6_bit = 1; // set RB6 pin as input
TRISB7_bit = 1; // set RB7 pin as input
Spi1_Init();
Expander_Init(0); // Initialize Port Expander
Expander_Set_DirectionPortA(0,0x00); // set expander's porta to be output
Expander_Set_DirectionPortB(0,0x00); // set expander's portb to be output
Expander_SetBit_PortA(0, 0x00);
//Expander_Set_PullUpsPortA(0, 0xFF);
//Expander_Set_PullUpsPortB(0, 0xFF);
while(1)
{
//Expander_SetBit_PortA(0, 0x01); //1ère led A0
//Expander_SetBit_PortA(0, 0x02); //1ère led A1
// Expander_SetBit_PortA(0, 0x04); //1ère led A2
//Expander_SetBit_PortA(0, 0x08); //1ère led A3
//Expander_SetBit_PortA(0, 0x0B); //1ère led A4
//Expander_Write_PortA(0, 0x01);
//Expander_Write_PortA(0, 0x02);
//Expander_Write_PortA(0, 0x04);
//Expander_Write_PortA(0, 0x08);
Expander_Write_PortA(0, 0b00000000);
Delay_ms(2000); /* One second pause */
Expander_Write_PortA(0, A);
Delay_ms(1000); /* One second pause */
Expander_Write_PortA(0, B);
Delay_ms(1000); /* One second pause */
//Expander_Write_PortA(0, 0b00000000);
//G = A ;
G = (A|B);
Delay_ms(1000); /* One second pause */
Expander_Write_PortA(0, G);
}
} Lorsque je fais ce calcul G = (A|B);, aucune des deux ne s'éclaire alors quzavec la table de vérité, ca devrai le faire.
J'ai encore loupé quelque chose
François


