chipKIT® Development Platform

Inspired by Arduino™

UART Rx on 39 not working?

Created Tue, 01 Apr 2014 14:53:47 +0000 by TechnoX


TechnoX

Tue, 01 Apr 2014 14:53:47 +0000

Hi!

I'm trying to communicate between a Cubieboard and the Chipkit using UART. I have also tried to communicate with a GSM module with UART. It seems that I can send data, but not recieve data.

Now I have borrowed an extra Chipkit and trying to communicate between them. I can communicate with the UART on pins 0 and 1 (only when I disconnect the USB), but not on the one at pins 40 and 39. I can send data using pin 40.

I have tried both chipkits and neither of them are able to recieve data on pin 39. I don't think I have fried this pin. Can I verify it somehow? But it would be strange if both Chipkits were fried.

I could use pins 0 and 1, but I prefer to use these for debug by USB. And I can't debug and use UART at the same time?

I were a bit confused if I should use Serial, Serial1 or Serial0. Because in AVR they tend to start at 0 and in PIC 1. But it seems that Serial1 is for the UART on pin 39 and 40? :)

My code in the master:

void setup(){
    Serial1.begin(9600);
    pinMode(43,OUTPUT);
}

void loop(){
    if(millis()%1000==0){
        Serial1.write(1);
        digitalWrite(43,HIGH);
        delay(100);
    }
    digitalWrite(43,LOW);
}

Sends a ping every second and display this at the LED.

And in the slave

void setup(){
    Serial1.begin(9600);
    pinMode(43,OUTPUT);
}

void loop(){
    if(Serial1.available()){
        digitalWrite(43,HIGH);
        delay(50);
        Serial1.read();
    }
    digitalWrite(43,LOW);
}

Check for new data and flash the LED if we recieve anything.

The slave never lights the LED when using Serial1 and cable connected to 39. If I change the program to use Serial and the cable to pin 0 it lights up the LED everytime the master flashes.

Thanks in Advance!


majenko

Tue, 01 Apr 2014 15:00:47 +0000

Some clarification on Serial numbering:

  1. The "base" serial port - that is the one that is connected through the USB to the PC - is always "Serial".
  2. If you have a board with a "direct" USB connection, such as a Fubarino, or a WF32 using the second USB port, that port is "Serial", and the lowest UART is renamed to "Serial0".
  3. All subsequent serial ports are numbered "Serial1", "Serial2", etc.

Now... question...

Which chipKIT boards are you using?


TechnoX

Tue, 01 Apr 2014 17:25:08 +0000

Okay, I see :)

Sorry, forgot to mention, I'm using the Uno32.


majenko

Tue, 01 Apr 2014 17:33:57 +0000

And now one more question... what version of MPIDE are you using...?


TechnoX

Tue, 01 Apr 2014 17:40:47 +0000

mpide-0023-windows-20130715 :)


majenko

Tue, 01 Apr 2014 18:14:47 +0000

I thought you might be. That's seriously old and has a huge bug in the serial code.

Download a newer version from here: [url]http://chipkit.s3.amazonaws.com/index.html[/url]


TechnoX

Tue, 01 Apr 2014 18:43:04 +0000

Thanks! I will try it out :)

I just followed the link on this page: http://chipkit.net/started/install-chipkit-software/install-mpide-windows/ I thought it was the most recent version. But I see that it wasn't the case.

EDIT: Yes! It works perfect! Thanks for the help! :D