Go Down

Topic: MDB USART mystery (Read 1 time) previous topic - next topic

aggrav8d

Hello!

I have connected an UNO R3 to a circuit desribed in the NAMA MDB 4.2 standard so that I can "talk" to a vending machine.
Code: [Select]
void init_MDB() {
  // Set baud rate
  UBRR0H = UBRRH_VALUE;
  UBRR0L = UBRRL_VALUE;
  // Disable USART rate doubler (arduino bootloader leaves it enabled...)
  UCSR0A &= ~(1 << U2X0);

  // Set asynchronous
  UCSR0C = (0<<UMSEL01)|(0<<UMSEL00);
  // set 1 stop bit
  UCSR0C |= (0<<USBS0);
  // set no parity
  UCSR0C |= (0<<UPM01)|(0<<UPM00);
  // set 9bit
  UCSR0C |=(1<<UCSZ01)|(1<<UCSZ00);
  UCSR0B |= (1<<UCSZ02);

  UCSR0B |= (1<<RXEN0);  // Enable RX
  //UCSR0B |= (1<<TXEN0);  // Enable TX
}

I can receive data just fine.  When I try to enable transmission
Code: [Select]
  UCSR0B |= (1<<TXEN0);  // Enable TX
The vending machine goes into "out of service" mode.  I am not sending anything.  The only thing I've done is enable this bit.

Is it possible that the arduino is transmitting and I don't know it?  Maybe TX is set to HIGH or something?

Should I disable TX while I don't need it?

Will toggling it at run time introduce noise to the network and screw things up?

Thank you.
Dance as if no one is watching; post as if it is going to be read aloud as evidence in court.

Go Up