USART without reciever

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good day All,

 Most of my projests to date have been on Arduino Nano hardware using AVR-GCC and libraries I have borrowed from Dean etc. or rolled on my own, and most (all) to date have an active serial interface for interracting and debugging.

But, my latest projest I want to be able to run with or without a 'client' serial device attached, but without the serial plugged in the device doesn't start! This is using the usb->serial via *not* an FTDI (clone/replacement/PL...).
Can anyone advise as to how to change my USART code to allow transmission without a reciever?

Here are the relevent bits:

 

/* usart enable send/recv mode: 8N1 @ baude */
void init_usart(uint16_t baude, uint32_t fcpu) {
    UCSR0B = (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0);
    UCSR0C = (1 << UCSZ00) | (1 << UCSZ01);
    UBRR0 = fcpu / 16 / baude - 1;
}

/* write a single byte to the usart */
void send_char(uint8_t byte) {
    while (!(UCSR0A & (1<<UDRE0)));
    UDR0 = byte;
}

In my mainloop after initialisation I send a message saying welcome to this blah that version whatsits... the micro waits until I have done something like "screen /dev/ttyUSB*" and the screen session starts before t progresses.

Cheers.

Jasper

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why do you enable rx interrupts?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most if not all of the Arduinos have their reset tied to either the DTR or RTS signal of the serial port, and opening the serial port on the computer plays with those signals and causes the Nano to reset. Depending on the board you can cut the trace on the PCB that connects the reset to the DTR/RTS signal. I'm not sure if that's even possible on the Nano.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

christop wrote:

Most if not all of the Arduinos have their reset tied to either the DTR or RTS signal of the serial port, and opening the serial port on the computer plays with those signals and causes the Nano to reset. Depending on the board you can cut the trace on the PCB that connects the reset to the DTR/RTS signal. I'm not sure if that's even possible on the Nano.

That is another annoyance! Thank you, will look to see if I can cut the relevent traces... or the pin on the FTDI...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I was going to use interrupts for USART at some point.

 Again, epressing ignorance, is there an issue with doing that if I have an application where time critical acivites are carried out on timer overflow via interrupt? (as in will the USART via interrupt block these events?)

 

Cheers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Enabling an interrupt without an associated isr will most likely cause the AVR to reset. By default, a currently executing isr will block other interrupts whilst it runs. Whether or not this would negatively affect other interrupts depends on your code and the timing requirements.

Last Edited: Tue. Oct 28, 2014 - 08:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To disable the receiver make RXEN and RCIE zeros

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To disable the receiver make RXEN and RCIE zeros

As they default that way surely that simply means "don't touch them"? So:

    UCSR0B = (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0);

becomes just

    UCSR0B = (1 << TXEN0);

Last Edited: Wed. Oct 29, 2014 - 09:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

To disable the receiver make RXEN and RCIE zeros

As they default that way surely that simply means "don't touch them"? So:

    UCSR0B = (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0);

becomes just

    UCSR0B = (1 << TXEN0);

Well yeah............

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Wed. Oct 29, 2014 - 11:38 PM