Basically I'm trying to get a very basic 2-1 MUX programmed into my PIC. This is what I have...It's not working the way it is supposed to...and I'm not sure why? Eventually this needs to be a 4-1 MUX can I get any tips or advice?
#include <p18f4520.h>
#include <delays.h>
#pragma config OSC = INTIO7
#pragma config WDT = OFF
#pragma config LVP = OFF
/*selOne = RA0, selTwo = RA1*/
int Ain, Bin, Cin, Din, selOne, selTwo;
unsigned char Dout=0;
/*Main Function*/
void main(void)
{
/*Settings*/
TRISD=0b00000000; /*Declaring all PORTD as Output port*/
TRISA=0b11111111; /*Declaring all PORTA as Input port*/
TRISB=0b11111111; /*Declaring all PORTB as Input port*/
PORTAbits.RA0=selOne;
PORTBbits.RB0=Ain;
PORTBbits.RB1=Bin;
while(1) /*Loop Forever*/
{
if(selOne==0)
{
Ain=PORTDbits.RD0;
}
else
{
Bin=PORTDbits.RD0;
}
}
}
#include <p18f4520.h>
#include <delays.h>
#pragma config OSC = INTIO7
#pragma config WDT = OFF
#pragma config LVP = OFF
/*selOne = RA0, selTwo = RA1*/
int Ain, Bin, Cin, Din, selOne, selTwo;
unsigned char Dout=0;
/*Main Function*/
void main(void)
{
/*Settings*/
TRISD=0b00000000; /*Declaring all PORTD as Output port*/
TRISA=0b11111111; /*Declaring all PORTA as Input port*/
TRISB=0b11111111; /*Declaring all PORTB as Input port*/
PORTAbits.RA0=selOne;
PORTBbits.RB0=Ain;
PORTBbits.RB1=Bin;
while(1) /*Loop Forever*/
{
if(selOne==0)
{
Ain=PORTDbits.RD0;
}
else
{
Bin=PORTDbits.RD0;
}
}
}