Can SPI SS pin be used as PWM output by slave?

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

Working on designing an ESC for BLDC motor and I need 6PWM. I am using ATMEGA328p-AU. I need to program the M328p after its in the PCB so I need to leave some pin outs for SPI. But some PWM and SPI pins are same. I applied a switch/buffer between MISO and MOSI. But to enable the SPI mode, I would always need the SS pin as input while also need it in PWM. What can I do?

 

If possible can I change SS pin? 

Last Edited: Tue. Feb 23, 2021 - 10:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

The SS pin is not required by the SPI in master mode, although it does need to be made an output to prevent it from switching the SPI from master to slave mode.

So you can use it for any other purpose as an output pin, also you can use any other free pin as your SS output to other external SPI devices.

Hope that helps.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Do you have a strong reason to use mega328p?

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

ki0bk wrote:
The SS pin is not required by the SPI in master mode,

It's not entirely clear to me, but isn't the OP talking about slave mode ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...