AVR DB series and re-assigning the MISO pin after setting up HW SPI?

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

 

AVR DB series and re-assigning the MISO pin after setting up HW SPI? 

 

I have a 28-pin (DIP) AVR 128 DB 28 micro and I am running a couple of little tests on this new-to-me micro and Bascom.

 

I am running the uC on 3V and using the DUAL power supply option, so that Port C is actually running on 5V.

 

On this somewhat limited pin count DIP Chip there are only 4 I/O pins, (PortC), that run on the dual voltage, (+5V in this case).

 

PortC.0 = SPI MOSI

PortC.1 = SPI MISO

PortC.2 = SPI Sck

PortC.3 = SPI CS\

 

I currently have an SPI based 7-Segment LED display running on the Hardware Port C SPI module.

That works fine.

 

The display is an input only device, and doesn't feed any data back to the micro on the MISO pin.

 

I would like to use that "spare" MISO pin as a general purpose 5V I/O pin.

 

The question is:  Can I re-configure the PortC.1 MISO Pin as a general purpose Output pin after the HW SPI is configured, or is that pin solely committed to the HW SPI module?

 

I have tried re-configuring the pin, after configuring the HW SPI module, but that doesn't appear to work.

I think that the pin is committed to the HW SPI module.

 

I --> thought <-- that I had done this before, on an older AVR.

 

If anyone has successfully done this I'd like to know, as then I at least know it is doable if I get my code right.

If anyone has tried this in their language of choice and it also fails, that is depressing but reassuring at the same time.

 

I'd post "a small compilable working example" but:

My program is in Bascom.

It is running on a Beta version that will support the AVR DB series.

So I doubt any other Freaks have the Beta compiler to test the program on.

 

Also, the question is really about whether anyone else's compiler can actually re-configure the AVR DB series SPI MISO pin as a general purpose output after configuring the HW SPI module, (so my Basic program wouldn't likely be too helpful).

 

I could ask MicroChip Support, but in the past I have had difficulty getting a specific answer to my specific questions.

I usually get a better answer here!

 

Any insight, or ideally an "Of course its possible" answer, would be appreciated!

 

JC

 

 

Edit: Typo...

 

 

Last Edited: Sun. Oct 3, 2021 - 07:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

DocJC wrote:

PortC.0 = SPI MOSI

PortC.1 = SPI MISO

PortC.2 = SPI Sck

PortC.3 = SPI CS\

 

?

 

PORTC has no SPI on the 28 pin part.

 

opps, it does, my bad, I have not used it yet.

 

How does Bascom know which SPI (0/1) to init?

 

Last Edited: Sun. Oct 3, 2021 - 08:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe using USART in SPI mode? It has separate  enables for TX and RX.

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

In such cases, I use USART's MSPI behavior.

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

Ron,

Bascom currently supports the HW SPI on PortA, (SPI-0).

The Beta is being updated to also support the HW SPI on Port C, (SPI-1). 

 

Currently I use Bascom's commands (instructions) to configure and send data out SPI-0.

I set the registers to configure the SPI-1 myself, and send data to it by writing to the registers, not through the high level language constructs.

(Once the Beta is updated I can just use the Basic instructions.)

 

Bascom also supports a SW SPI on any pins, but interestingly one can use one or both HW SPI's, but one can't mix the SW and a HW SPI.

 

Balisong and Kabasan, 

What a great work-around solution!

You rock.

I had totally forgotten about the USART in SPI Mode option!

USART-1 is on the lower nibble of PortC, just where I need it to be for the Dual Voltage functionality.

 

I'll have to give it a try!

 

Thank you!

 

JC

 

 

Last Edited: Sun. Oct 3, 2021 - 11:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


So, an update:

Once the HW SPI module is initialized I am still unable to re-assign the (unused) MISO pin for general use.

 

I did configure USART-1, on PortC, (and hence on +5V, as opposed to the remainder of the micro which is running on +3V), for use as an SPI Master.

Doing so allows one to individually turn on or off the SPI TxData and RxData parts of the SPI.

That allowed me to use the SPI output to drive the 7-Segment display, and the SPI "input", unused and re-assigned, to drive the WS2812B digital LEDs.

 

The PortA SPI is driving the 3V Nokia GLCD.

It is displaying the DS18B20's temperature reading, and the Sensirion sensor's temp & relative humidity.

 

It is very cool to have both +3V and +5V peripherals running on the uC without any (external) level conversion interface required.

 

Thank you, again, for the suggestion, it is working well!

 

JC

 

 

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


Another way to proof-of-concept (Phase Dock) :

The Evolution of Breadboarding | DigiKey

[2/3 page]

A breadboard mix for today’s designs

...

"Dare to be naïve." - Buckminster Fuller

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

Interesting article.

 

The article used an Analog Devices ADL6012 to demonstrate "demo" boards.

So I had to look it up to see what the chip was.

 

I'll keep that chip in mind next time I need a 67 GHz, (Yes, Giga-Hz), envelope detector!

 

It will do nicely for my Nano based ship-board HARM AGM-88 missile detector system.

 

JC