uart 18f4550

General discussion on mikroC.
Post Reply
Author
Message
viorel.sorescu
Posts: 3
Joined: 07 Apr 2011 21:39

uart 18f4550

#1 Post by viorel.sorescu » 07 Apr 2011 22:22

hello, and I want to make a communication between a computer and wireless module pic18f4550. All goes well in that the microcontroller gets what I send from my computer but not return back to your computer. Wireless communication is good, but the pin 25 "TX "that is at port" c "I do not send anything to the wireless, I think it is registry settings, using a 4 MHz oscillator, and communication is 9600 baud. Attached and the software but I tried several variants of the mikroc help and we could not send anything to the microcontroller, I repeat it receives from wireless and microcontroller work I tested it with several software switch on my lights and some other stuff.

Code: Select all

void main() {

        ADCON1 |= 0x0F;
        CMCON  |= 7;

        Uart1_Init(9600);

        while(1){
         UART1_Write_Text("this is a UART output test at 9600 BAUD\n\r");
         delay_ms(1000);
        }
}

viorel.sorescu
Posts: 3
Joined: 07 Apr 2011 21:39

Re: uart 18f4550

#2 Post by viorel.sorescu » 08 Apr 2011 08:51

the software below fail to ignite the pins 18,23,24,25 thus fail to do anything I think is 25 pin settings

Code: Select all

void main() {

  ADCON1 |= 0x0F;      // Configure AN pins as digital
  CMCON  |= 7;         // Disable comparators

  TRISA = 0;           // set direction to be output
  TRISB = 0;           // set direction to be output
  TRISC = 0;           // set direction to be output
  TRISD = 0;           // set direction to be output
  TRISE = 0;           // set direction to be output

  do {
    PORTA = 0x00;      // Turn OFF LEDs on PORTA
    PORTB = 0x00;      // Turn OFF LEDs on PORTB
    PORTC = 0x00;      // Turn OFF LEDs on PORTC
    PORTD = 0x00;      // Turn OFF LEDs on PORTD
    PORTE = 0x00;      // Turn OFF LEDs on PORTE

    Delay_ms(1000);    // 1 second delay

    PORTA = 0xFF;      // Turn ON LEDs on PORTA
    PORTB = 0xFF;      // Turn ON LEDs on PORTB
    PORTC = 0xFF;      // Turn ON LEDs on PORTC
    PORTD = 0xFF;      // Turn ON LEDs on PORTD
    PORTE = 0xFF;      // Turn ON LEDs on PORTE

    Delay_ms(1000);    // 1 second delay
  } while(1);          // Endless loop
}

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: uart 18f4550

#3 Post by Sparky1039 » 08 Apr 2011 17:53

Due to read-modify-write issues with the PIC port hardware, try using the LATx command instead of PORTx. Note: This hint only applies to 18F and above devices. 10F, 12F, 16F devices do not have LATx registers.

Code: Select all

while (1) {
LATB = 0xFF;
delay_ms (200);
LATB = 0x00;
delay_ms (200);
}

viorel.sorescu
Posts: 3
Joined: 07 Apr 2011 21:39

Re: uart 18f4550

#4 Post by viorel.sorescu » 12 Apr 2011 11:51

I set to 9500 baud and I usart 4-MHz oscillator, little is running correctly, but does not send anything back to PC 25 pin that is not sending anything tx

Post Reply

Return to “mikroC General”