Jump to content


Photo

UART problems


  • Please log in to reply
25 replies to this topic

#21 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:16 PM

Bill, 
Thanks for the source.   Better late than never on my end too.   I'm still using your code although I have found some examples of how to set up the pinmode for  the pcDuino on the sparkfun tutorial page at https://learn.sparkf...-communications and was able to carve out the pinmode setup from the example on this page and get it to work.   However, when I tried my code on pcDuino v2 it didn't work nor did setuart2.  It's probably some problem in my hardware connection but, I am worried they changed something in the device drivers which broke my and your code.  Having your source I can dig deeper.  If you know anything about this issue I'm sure you will let me know.   Thanks again for the source. 
Mark



#22 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:17 PM

Since the kernel code is the same for the pcDuino and pcDuino v2, I can not see an immediate reason why the pin mode setting would not work. I will look at getting a v2 to test.

Thanks for the head up.

Enjoy!
Bill



#23 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:17 PM

Back to square one with pcDuino V2.   setuart2 no longer works.   The linux image is quite a bit different from what's on V1.  It has a board config at the begining like a bios, It detects my full 1080P monitor and displays at full resolution ( a good thing) and they have added a /home/ubuntu/samples/core/ directory with a couple executables  for setting gpIOs but unfortunately nothing for initializing the ttyS1 serial port.  The serial_test example code from github didn't work for me either. 



#24 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:17 PM

Also had the same problem on pcDuino3. Also, I'm using perl and not python / c - from command line.

Since outputting 1 on the GPIO0/GPIO1 mode flags didn't do the trick ... I tried to test the loopback method mentioned here http://learn.linkspr...est-on-pcduino/ . It worked - but I had to change the import from core.h to Arduino.h (using c_environment):

#include <Arduino.h>
#include "Serial.h"

void setup() {
        Serial.begin(115200);
        while (!Serial);
}

void loop()
{
        Serial.println("Hello, world");
        while (Serial.available() > 0) {
                int ret = Serial.read();
                printf("I received:0x%.2x(%c)\n", ret, ret);
        }

        delay(10);
}

and the output looks like:

I received:0x48(H)
I received:0x65(e)
I received:0x6c(l)
I received:0x6c(l)
I received:0x6f(o)
I received:0x2c(,)
I received:0x20( )
I received:0x77(w)
I received:0x6f(o)
I received:0x72(r)
I received:0x6c(l)
I received:0x64(d)
I received:0x0a(
)
I received:0x0a(
)
I received:0x0a(
)

After running the test, magically somehow, the communication with the serial device also started to work! I realized it is something related to the pin modes, so I went to check the code in Serial.begin(). It seems that the Serial.cpp sets the mode to value 3 (IO_UART_FUNC) for the two RX/TX pins.

So now, in command line:

ubuntu@ubuntu:~/c_environment/work/uart_test$ echo 3 > /sys/devices/virtual/misc/gpio/mode/gpio0
ubuntu@ubuntu:~/c_environment/work/uart_test$ echo 3 > /sys/devices/virtual/misc/gpio/mode/gpio1

and then the serial communication with the device started to work smiley.gif



#25 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:18 PM

Hi Bill 

Can you please share the test code you made for UART2.

Thanks
Jovanov



#26 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:18 PM

Mr. Bill Thank You So Much for your brilliant code. It worked fine for me.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users