Go Down

Topic: PortD PIN 1 (TX) is ON for around 2 seconds when Arduino turns on (Read 982 times) previous topic - next topic

srossel

Ladies and Gentlemen,

Good Morning!

I have been working with the Arduino UNO, ATMEGA328P microcontroller, and I have been experiencing the following issue:

I am controlling some stuff at home using the PORTD, from pin 0 to 7. Unfortunately, When I plug in the Arduino to the power source, the PIN 1 (TX) is turning on for around two seconds and then it turns off. This issue provokes the involuntary turning on of one of the devices that I am trying to control.

In  my esketch, I have the PORTD initialized as PORTD = B00000000, so all the outputs gonna be off until other part of the logic gonna start activating them in the way that I want. The esketch is not the problem, my program works exactly in the way that I want. It is just at the very beginning when I plug in the system and the PIN 1 (TX) turn on for the time mentioned before.

 Is there a way to configure/controll this pin to be off all the time before my program start working as expectd?

My presumption for this problem is in the boot of the microcontroller. Somehow some part of the boot logic is verifying the TX and allowing the PIN 1 to be on. How can i get ride of this?

Thank you very much, and I look forward to hear from you guys!

Cheers!

Paul__B

Very simple.

Do not use pins 0 or 1 in a sketch.

Or:

Use ISP programming so the bootloader is removed.

srossel

Paul_B,

Unfortunately, I cannot get ride of pin 0 and 1, I need them.

When you say, "Use ISP Programming", what exactly you mean?  When I research for that I found these two  websites http://arduino.cc/en/Guide/ArduinoISP  and  http://arduino.cc/en/Tutorial/ArduinoISP, so I guess it should be a kind of combination on the hardware configuration that I need to configure with my breadboard and then instead loading  the "Bootloader" into the microcontroller, I have to use the "Upload using Programmer" to upload my esketch, is that what you mean?

I have been reading the instructions, but it's not clear for me yet. do you have any website that can explain it clearly ?

Thank you!

Coding Badly

Unfortunately, I cannot get ride of pin 0 and 1, I need them.
All the other 18 pins have something connected?


westfw

The problem is that the bootloader enables the serial port, which is on pins 0 and 1.  While it won't actually send data unless it sees "boot" commands, the idle state for a serial port is "on", so TX is on for the time that the bootloader is looking for data.

One way around this is to delete the bootloader.  But then you'll need another way of loading your sketch onto the AVR chip.  "ISP Programming" is one way - you attach an external programmer to the ISP signals and burn the sketch using the "upload using programmer" option.

Note that pin 0 (RX) is tied to the FTDI transmit pin, which will also be "ON" most of the time (actually, I'm not sure what it does when no USB cable is plugged in.)  This is a hardware limitation and you have less control over it than over the TX pin.

srossel

Okay, This is what I did.

I consideration of Paul_B comment about "ISP Programming", I procedded to research a little bit and upload the sketch with "Upload Using Programmer" option. Here are the steps:

BEFORE start, just for your consideration, the microcontroller that I wanted to burn is the ATmega328P-PU, where signature is 0x1e 0x95 0x0F (I will explain it in step xxxx).

1.- Get a new USB Printer cable just in case the one that you have may have problems.

2.- Close your arduino IDE environment, and disconnect your Arduino UNO Board from your computer.

2.- Downgrade Arduino IDE to version 1.0.x, in my case I choose 1.0.5 , available under Arduino Downloads (So Unistall Arduino and Install this old version).

3. Modify the Boards.txt file ("C:\Program Files (x86)\Arduino\hardware\arduino"), adding the following code:


Code: [Select]

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

##############################################################

westfw

Um, you shouldn't have to do most of that for programming an actual Uno.  Most of it is instructions for a stand-alone chip, with different circuitry.

Just use the "Programmer" menu to set the programmer, the "Serial Port" to the port with the programmer (if necessary - depends on programmer type), and do "upload using programmer."

Paul__B


Go Up