ATmega328PB - using UART1 in addition to SPI0 port

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

Hi guys,

I'm working on a new project on the ATmega 328PB, where I need to use a second UART.
Using UART1 in addition to the SPI0 port, which also is the programming port, might cause problems,
as they use the same pins (MISO0 = RXD1 ; MOSI0 = TXD1).
Or am I wrong?
Changing the configuration registers on the fly to use either UART1 or SPI0 (e.g. spi display) should be possible.
But what about the hardware?
UART1 of the 328PB e.g. connected to a second ATmega's UART would cause problems for any components connected to SPI0.

Does anyone have an idea how to get this working?

Many thanks!

 

 

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

With a /CS pin high any spi device should ignore any usart traffic, but getting the USART to ignore any SPI traffic will be harder to do, perhaps use some h/w handshaking RTS/CTS via two more port pins.

The other alternative is to use softuart to keep the two separate or bit bang the spi on separate pins (easier to do then softuart).

Sounds like its time to review the design again and see if the M328PB is the right chip for the job.

 

Jim

 

 

 

 

 

Last Edited: Fri. Nov 2, 2018 - 03:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Are you only concerned with the "programming port" part?  If so, the situation has been around as long as AVRs, as some model families have the ISP pins on UART pins.  If you are programming then the AVR is in reset, so the UART will not be active.

 

Find a Mega128 design schematic, and note the isolation resistors.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Many thanks for your input!

 

The the only SPI device would be a display with just an input (MOSI -> display) physically connected to the RXD input of the second ATmega might work, as this input is idle floating.

Not using the MISO input at all, physically connected to the TXD output of the second ATmega (idle HIGH), should also make no problems.

Is this agreed?

Then everything would be fine....