View unanswered posts | View active topics It is currently Thu Oct 02, 2014 10:28 am






Reply to topic  [ 11 posts ] 
Bug Report:RX/TX ports don't work as IO ports when debugging 
Author Message
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Bug Report:RX/TX ports don't work as IO ports when debugging
I've the following code:

Code:
#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(Sensor, dgtl0,  ,               sensorDigitalOut)
#pragma config(Sensor, dgtl4,  ,               sensorDigitalOut)
#pragma config(Sensor, dgtl12, ,               sensorDigitalOut)
#pragma config(Sensor, dgtl13, ,               sensorDigitalOut)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  wait1Msec(5000);
 
  SensorValue(dgtl13) = 1;
  SensorValue(dgtl12) = 0;
 
  SensorValue(dgtl0) = 0;
 
  while(true)
  {
    SensorValue(dgtl4) = 1;
    wait1Msec(500);
    SensorValue(dgtl4) = 0;
    wait1Msec(500);
  }
}


This should blink the LED on pins 4 and 0 when the LED on pins 13 and 12 turn on. The second LED turns on, but the first one doesn't. I've tried it with both pins 0 and 1, so one would logically conclude that the RX/TX ports do not work as general digital I/O.

EDIT: I've edited the title to be more specific.
EDIT Reduex: Title even more specific.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Last edited by NeXT-Generation on Thu May 17, 2012 12:43 pm, edited 2 times in total.



Wed May 16, 2012 11:06 am
Profile WWW
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
NeXT-Generation wrote:
This should blink the LED on pins 4 and 0 when the LED on pins 13 and 12 turn on. The second LED turns on, but the first one doesn't. I've tried it with both pins 0 and 1, so one would logically conclude that the RX/TX ports do not work as general digital I/O.


Normally you don't want to use digital pins 0 and 1 except for serial communications. If you have the Arduino hooked up to your USB that will interfere with it (this is how the Arduino is wired, same thing happens using Serial monitor in Arduino IDE).

Besides that I am a bit confused by something you said. There is no code (that I see of) that blinks pin 0. You only make one call before the while loop that turns pin 0 off.


Wed May 16, 2012 11:26 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
Dennis Mabrey wrote:
NeXT-Generation wrote:
This should blink the LED on pins 4 and 0 when the LED on pins 13 and 12 turn on. The second LED turns on, but the first one doesn't. I've tried it with both pins 0 and 1, so one would logically conclude that the RX/TX ports do not work as general digital I/O.


Normally you don't want to use digital pins 0 and 1 except for serial communications. If you have the Arduino hooked up to your USB that will interfere with it (this is how the Arduino is wired, same thing happens using Serial monitor in Arduino IDE).

Besides that I am a bit confused by something you said. There is no code (that I see of) that blinks pin 0. You only make one call before the while loop that turns pin 0 off.


Oh. I didn't know that. If that's true, then why is there the option to use them as such?

One LED is connected to pins 0 (or 1) and 4. The other to pins 12 and 13. Pin 0 (or 1) is initialized to GND, and pin 4 switches between GND and 5V, hence blinking the LED.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed May 16, 2012 11:43 am
Profile WWW
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
NeXT-Generation wrote:
Oh. I didn't know that. If that's true, then why is there the option to use them as such?


Well it only causes a conflict when you are using the USB for serial data transfer / program download / debugging. If you did not have the Arduino connected to your PC they should work like normal digital pins. Generally people don't use those two pins unless it is for serial communications such as communicating with a GPS.

The Arduino website says the following: You should note, however, that pins 0 & 1 are used for serial communications for programming and debugging the Arduino, so changing these pins should usually be avoided unless needed for serial input or output functions. Be aware that this can interfere with program download or debugging.
(see http://www.arduino.cc/en/Reference/PortManipulation )

NeXT-Generation wrote:
One LED is connected to pins 0 (or 1) and 4. The other to pins 12 and 13. Pin 0 (or 1) is initialized to GND, and pin 4 switches between GND and 5V, hence blinking the LED.


Oh. Ok well try changing the code from pin 0 to a different digital pin.


Wed May 16, 2012 12:12 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
Dennis Mabrey wrote:
NeXT-Generation wrote:
Oh. I didn't know that. If that's true, then why is there the option to use them as such?


Well it only causes a conflict when you are using the USB for serial data transfer / program download / debugging. If you did not have the Arduino connected to your PC they should work like normal digital pins. Generally people don't use those two pins unless it is for serial communications such as communicating with a GPS.

The Arduino website says the following: You should note, however, that pins 0 & 1 are used for serial communications for programming and debugging the Arduino, so changing these pins should usually be avoided unless needed for serial input or output functions. Be aware that this can interfere with program download or debugging.
(see http://www.arduino.cc/en/Reference/PortManipulation )

NeXT-Generation wrote:
One LED is connected to pins 0 (or 1) and 4. The other to pins 12 and 13. Pin 0 (or 1) is initialized to GND, and pin 4 switches between GND and 5V, hence blinking the LED.


Oh. Ok well try changing the code from pin 0 to a different digital pin.


I didn't know all that. Thanks! :bigthumb: I guess I'll just have to make it a bit more complicated. My current design was going to use all pins but one, but I guess I can Charlieplex some of the LEDs.

EDIT: Though I can't get this to work in RobotC, it works perfectly fine with the standard Arduino software. How odd.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed May 16, 2012 12:27 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
Just an update: I've been able to get the RX/TX lines working as I/O with no problems in Arduino soft, but no matter what I try can't get them to work with RobotC. I think that that's kinda weird. Oh well. Guess my wiring will just have to be more complicated.....

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu May 17, 2012 10:29 am
Profile WWW
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
NeXT-Generation wrote:
Just an update: I've been able to get the RX/TX lines working as I/O with no problems in Arduino soft, but no matter what I try can't get them to work with RobotC. I think that that's kinda weird. Oh well. Guess my wiring will just have to be more complicated.....


Were you running the debugger in RobotC at the time? The debug information is passed to the PC over the serial ports (and pins 0 and 1 are connected to serial).

It will work fine with the Arduino IDE until you call Serial.println() in your loop function with the serial monitor running. You will see problems in that case.

I was going to ask if you tried it while connected to external power only. I will try something later today when I get into the office.


Thu May 17, 2012 11:18 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
Hmm. I hadn't thought of USB interfering. So....

Running this code....
Code:
#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(UART_Usage, UART0, uartSystemCommPort, baudRate200000, IOPins, dgtl1, dgtl0)
#pragma config(Sensor, dgtl9,  ,               sensorDigitalOut)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  wait1Msec(5000);
 
  SensorType(UART0) = uartNotUsed;
  SensorType(dgtl0) = sensorDigitalOut;
  SensorValue(dgtl0) = 0;
 
  while(true)
  {
    SensorValue(dgtl9) = 1;
    wait1Msec(200);
    SensorValue(dgtl9) = 0;
    wait1Msec(200);
  }
}


Plug in Power jack... Unplug USB.... waiting for the timer.... and the LED is blinking!!!! I hadn't thought to unplug the USB. Thanks, Dennis! Now it'll be much easier to port the Arduino code I've been testing.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu May 17, 2012 12:36 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
Setting the debugger to "snapshot" instead of "continuous" might also work, so you don't have to unplug the USB.

_________________
sudo rm -rf /


Thu May 17, 2012 12:38 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
magicode wrote:
Setting the debugger to "snapshot" instead of "continuous" might also work, so you don't have to unplug the USB.


Testing.... That also works!

Okay, so as long as it isn't communicating with RobotC, RX/TX lines work as expected. Thanks for the help, everyone! :bigthumb:

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu May 17, 2012 12:41 pm
Profile WWW
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Re: Bug Report: RX/TX ports don't work as GPIO ports.
magicode wrote:
Setting the debugger to "snapshot" instead of "continuous" might also work, so you don't have to unplug the USB.


Dang should have thought of that. :biggrin:


Thu May 17, 2012 1:17 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.