| Author |
Message |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 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 |
|
 |
|
Dennis Mabrey
Rookie
Joined: Mon May 14, 2012 3:24 pm Posts: 43
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
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 |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
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 |
|
 |
|
Dennis Mabrey
Rookie
Joined: Mon May 14, 2012 3:24 pm Posts: 43
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
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 ) Oh. Ok well try changing the code from pin 0 to a different digital pin.
|
| Wed May 16, 2012 12:12 pm |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
 |  |  |  | Dennis Mabrey wrote: 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 ) Oh. Ok well try changing the code from pin 0 to a different digital pin. |  |  |  |  |
I didn't know all that. Thanks!  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 |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 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 |
|
 |
|
Dennis Mabrey
Rookie
Joined: Mon May 14, 2012 3:24 pm Posts: 43
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
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 |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 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 |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 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 |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
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! 
_________________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 |
|
 |
|
Dennis Mabrey
Rookie
Joined: Mon May 14, 2012 3:24 pm Posts: 43
|
 Re: Bug Report: RX/TX ports don't work as GPIO ports.
Dang should have thought of that. 
|
| Thu May 17, 2012 1:17 pm |
|
|