Boot sequence/initialization w/ LED's on SPI

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

I have a program that uses a bunch of switches and LED's on the SPI interface using MOSI/MISO and GPIO's for latching. The problem I have is when turning on the AVR the LED's go crazy few seconds. Sometime all (24) light up. This can potentially burn out the 74HC595 shift register IC's used for the LED's. Also when say 20 or more of the LED's are lit up the 250mA wall wart power supply can't regulate and the AVR can get hung up.

I'm new to AVR's and microcontrollers in general and I'm wondering how I should initliaze things to get control of the LED's immediately. Do I just try to initialize the SPI and the Port used for the latches first in main()? Is there some other way I can control the boot up sequence of the AVR?

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

It would help if we could see your circuit. Without it we can only speculate.

Four legs good, two legs bad, three legs stable.

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

When you have potentially harmful things happen with hardware, you should design for it to be 'safe' when the AVR is in reset.

The AVR always takes a certain amount of time to start (SUT fuses). So your HC595 could be putting all its pins into a bad state before the AVR takes control.

Use external pull-up or pull-down resistors on the 'chip-select' or 'output-enable' pins. e.g. pull-up on /OE pin.

David.

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

A pic of the is attached. There's not much to it.

1) LED's are active high.
2) Switches are active low using external pullup resistors (since they're on SPI).

The details of the power supply are not really the issue, just a by product that adds insult to injury. What I really want to know is if there's any way to control the boot up sequence of SPI, Port, and Timer initialization so that the LED's can be initialized immediately and go through a boot sequence, instead of popping on in completely random states... sometimes all of them come on for 2-3 seconds.

I guess this is more of a general question that I can't find good info on and I'm sure those more experienced (which is everybody) may have input. Currently the program flow is as follows:

1) Main()
2) Initialize SPI
3) Initialize PortB
4) Initialize Timer0 (used for scanning/debouncing keys)
5) while(1)

Thanks for looking.

Attachment(s): 

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

Quote:
Use external pull-up or pull-down resistors on the 'chip-select' or 'output-enable' pins. e.g. pull-up on /OE pin.
makes sense, thanks for that bit of advise.

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

Well, the answer is pretty obvious. You have about 80 spare GPIO pins that could control the /OE pins of the HC595s.

You are using a crystal. So you need a realistic SUT for the AVR. This probably won't be long enough to burn out your 595s or power supply. However it might cause brown-outs or shut down a power supply regulator.

David.

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

Quote:
Well, the answer is pretty obvious. You have about 80 spare GPIO pins that could control the /OE pins of the HC595s.
Obvious to you ;) actually yes it is somewhat obvious now that you say it. Thanks for the input. Most of the GPIO will be used but there is headroom/extras.

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

Even if you don't have a spare GPIO, you could put an RC time-constant on the /OE pin. e.g. 10uF to VCC, 10k to GND gives 100ms time-constant.

David.