no output in portb with uart

General discussion on mikroElektronika website & forums.
Post Reply
Author
Message
matanb
Posts: 3
Joined: 01 Feb 2017 14:49

no output in portb with uart

#1 Post by matanb » 26 Feb 2017 11:53

hello
I'm trying to build a RC car with READY FOR PIC (pic18f45k22) and PS3 controller.
by now i recive the signal from the PS3 controller and show the button on my uart terminal, I'm using uart1 to work with the PC terminal and uart2 to recive information from the controller.
my buttons shown exeacly as i push but i dont recive any output on PORTB.
van anyone help me?

my code:

char uart_rd;
char count;
void main() {

anselb=0;
anselc=0;
anseld=0;

TRISC = 0xC0;
TRISD = 0xC0;
PORTC = 0x00;
PORTD = 0x00;

TRISB=0x00;
PORTB=0x00;

uart1_init(115200);
uart2_init(115200);
delay_ms(100);

while(1){

if(uart2_data_ready()==1){
uart_rd=uart2_read();
if(uart_rd==0x50){ // recive P
count=1;
}
else{
count++;
if(count==22){ // wheels left
if(uart_rd==0x01){
rb2_bit=1;
uart1_write_text("button_left");
}
if(uart_rd==0x00){
rb2_bit=0;
}
}
if(count==24){ // wheels right
if(uart_rd==0x01){
rb3_bit=1;
uart1_write_text("button_right");
}
if(uart_rd==0x01){
rb3_bit=0;
}
}
if(count==31){ // drive forward
if(uart_rd==0x01){
RB0_bit = 1;
uart1_write_text("button_X");
}
if(uart_rd=0x00){
RB0_bit = 0;
}
}
if(count==33){ // drive back
if(uart_rd==0x01){
RB1_bit=1;
uart1_write_text("button_triangle");
}
if(uart_rd==0x00){
RB1_bit=0;
}
}

}
}

}
}

PORTB is incharge of the 5v output to the mottors, RB0 and RB1 for driving foword and back, and RB1 and RB2 for the wheels right or left.

i really think that i missed something but i can't find execly what's the problem.

thank u


*edit*
i've found the problem.
thank u anyway

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: no output in portb with uart

#2 Post by filip » 09 Mar 2017 09:47

Hi,

I'm glad that that the issue is solved.

Regards,
Filip.

Post Reply

Return to “Website & Forums General Discussion”