4
\$\begingroup\$

FTDI seems to be a popular forum topic, but I can't seem to find an answer to a confounding issue I have. I'll try to give as many details as I can, since I can't seem to narrow down the issue.

I am using an ATmega328-PU (the cheaper problem-child for ArduinoISP users) with an FTDI 232-RL Breakout Board. I was able to burn the Arduino bootloader using the breakout board with no problem, as well as load the sketch I am using.

Now, I am trying to use the FTDI serial com port from my PC to interface with the 328. The only pins I am running from the breakout board to my board are the TX, RX and GND pins. I am using a Baud Rate from my serial port of 115200.

Symptoms: the RX indicator flashes consistently, so it's getting lots of happy bits from the PC. The TX indicator flashes for about 1 second, then quits. No happy bits from FTDI to ATmega328.

I have no reset button on my 328 circuit, just a resistor to +5V. I have a 16MHz external clock in my circuit. I have attached my sketch's setup code for additional reference.

Now, the questions:

1) Do I need to do anything with the CTS and DTR pins coming from the breakout board?

2) Is there an internal clock still on the ATmega328 that's screwing me up (even after the bootloader? If so, how would I go about disabling it?

3) Is there a need for a reset button in my circuit if the sketch is already loaded?

Hopefully someone can shed some light onto my issue. Much appreciated!

Here's the setup code (after declaring pins on 328):

void setup()   
{               
  DDRB |= (1<<1)  | (1<<2)  | (1<<3) | (1<<5) ; // BLANK, SS, MOSI, SCLK as OUTPUTS
  DDRD |= (1<<3)  | (1<<4) |  (1<<6) | (1<<7) ; // VPRG, XLAT, GSCLK, Debug as OUTPUTS
  DDRC = 255;

  XLAT_Low;
  BLANK_High;
  VPRG_Low;
  Debug_Low;

  //Timer 1 (16bit)
  TCCR1A  = (1<<WGM11) | (0<<WGM10);            // Fast PWM with ICR1 as top
  TCCR1B  = (1<<WGM13) | (1<<WGM12);            // Fast PWM with ICR1 as top
  TCCR1B |= (1<<CS12)  | (1<<CS11) | (1<<CS10); // external clock (T1) on rising egde
  TIMSK1 |= (1<<TOIE1);                         // enable overflow interupt
  ICR1    = Gray_Scale_Depth;                   // Grey scale depth for TLC-PW

  //Timer 0 (8bit)
  TCCR0A  = (1<<WGM01) | (0<<WGM00);            // CTC
  TCCR0A |= (0<<COM0A1) | (1<<COM0A0);          // Toggle on Compare Match
  TCCR0B  = (0<<CS02) | (0<<CS01) | (1<<CS00);  // No Prescaler
  OCR0A   = 0;                                  // f(OCR) = F_CPU/2/Prescaler

  //UART Initialisation
  UCSR0A |= (1<<U2X0);                                 // Double up UART
  UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);    // UART RX, TX und RX Interrupt enable
  UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ;    // Asynchrous 8N1 
  UBRR0H = 0;
  UBRR0L = 1; //Baud Rate 1 MBit   --> 0% Error at 16MHz

  //Enable global interrupts
  sei();

  //Configure SPI  
  SPCR = (1<<SPE)|(1<<MSTR);  
  SPSR = B00000000;   

  ptr=display_buffer;

}
\$\endgroup\$
  • \$\begingroup\$ (1) CTS and DTR need not be used during standard Serial data transfer. (2) There is a usable internal clock, but you'd have to specifically enable it first, so I think that's not a problem. (3) No need for reset; you're just UART receive and transmit. \$\endgroup\$ – boardbite Sep 2 '12 at 11:34
  • \$\begingroup\$ Have you tried a different simple sketch? Since you're running Arduino bootloader, how about a simple Serial.begin(115200); and Serial.print("abc"); -- what happens on the TX indicator and on your PC's serial terminal then? \$\endgroup\$ – boardbite Sep 2 '12 at 11:35
  • \$\begingroup\$ The setup you have posted for the USART above all seem correct to me. Can you provide some more information? (rest of sketch, link to modules you are using). Especially include your ISR (interrupt service routine code) as I am not sure how that is handled in an Arduino sketch. \$\endgroup\$ – justing Sep 2 '12 at 15:09
  • 2
    \$\begingroup\$ I think your interpretation of the TX and RX indicators is not correct. RX doesn't mean that the PC is sending data, TX does. \$\endgroup\$ – Jim Paris Sep 2 '12 at 19:14
  • \$\begingroup\$ Hard to know which is which without schematic of the LED's but at least the logic of the TX/RX assessment is broken - only one of the two will be driven by the PC/FTDI. The other will be driven by the ATMEGA and could not be disabled by the FTDI if the ATMEGA has been programmed to continuously transmit (since there is apparently no reset circuit such as the serial status control line to capacitor trick by which the FTDI/PC could be sending it back to the bootloader) \$\endgroup\$ – Chris Stratton Sep 3 '12 at 12:26
3
\$\begingroup\$

First of all,

Are you sure that the FTDI TX pin is connected to the RX pin of the Arduino and the RX FTDI pin to the TX pin of the arduino ?

In around 50% of the prototypes I have seen, there is a problem like that. Thus it's the fist thing to check.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.