Author Topic: Stupid beginner tricks, or, why did it take me so long to realize this?  (Read 1893 times)

0 Members and 1 Guest are viewing this topic.

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
 So I've had a schematic drawn up for a microcontroller project I am working on, for some time now. Built it on a breadboard, write the code, and it works. Now comes PCB layout, because I need dozens of these and I'm not going to point to point wire them all.
 Having some trouble getting it laid out in a logical manner, minimal back and forth between layers with vias, keeping the power section short and away from data lines, etc.

 Then it hit me, lounging in the pull the other day. Why am I using the pin assignments on the micro that I am? I took another look at the pinout of the micro. Wait a second - if I just switch around some pin assignments, I can orient the micro such that almost no lines need to cross from one side of it to the other, and few traces have to cross . Why was I so stuck on the original pin assignments?  There are no usage restrictions that made me chose the order I did, and the few that were driven by such things are able to remain unchanged in the new scheme of things. Anything flexible was moved around in a more logical layout order instead of some function grouping - I guess I was looking at it more as a programmer than a circuit designer. This will make layout of the board MUCH easier and keep the noisy bits like relays and servos far away from the inputs. Heck even the schematic should look cleaner, if I replace the micro model with one that uses the actual pinout instead of grouping all the IOs on one side of the block and the support stuff *VCC, GND, crystal, reset) on the other.

 And I envision most people looking at this and thinking "Well, DUH!"
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2647
  • Country: us
Been there...  Done that...
I switched MCU pin assignments several times on one project alone.    :palm:
Eliminated many trace crossings by just re-assigning pins and only needed trivial code changes.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
wait till you start playing with FPGA's.
Do the layout first. then assign pins.

I would really like to see processor makers make a totally capable pin mux so you can put anything anywhere. it doesn't cost that much logic.
Only power , crystal and reset pin should be 'hard'. The rest should be programmable. ( with the exception of USB )
Programming should be done using bootloaders over usb  or over 2 pins that change operation (tx/rx or sclk / sdio ) ( only when reset is physically held down longer than 3 seconds. The loader kicks in)
« Last Edit: July 01, 2019, 04:59:12 pm by free_electron »
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Been there...  Done that...
I switched MCU pin assignments several times on one project alone.    :palm:
Eliminated many trace crossings by just re-assigning pins and only needed trivial code changes.

 Right? And since all my pin assignments are in one well-commented block right at the top of the code - stupidly simple to fix.

 My next project should not have this issue, I'm using very few of the pins directly off the micro, the IO for that will come mostly from IO expanders. I can already see how to lay that out to give plenty of room for the IO connectors and not make a giant PCB with big unused areas. I'm learning! That's the good thing.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11720
  • Country: us
    • Personal site
I would really like to see processor makers make a totally capable pin mux so you can put anything anywhere. it doesn't cost that much logic.
It unfortunately does. Newer Atmel/Microchip MCUs have pretty flexible multiplexing (but not any to any). And for smaller devices all multiplexing options are available. But for bigger devices (like SAM E54) SERCOM unit (UART/I2C/SPI) pins are assigned in groups, and the whole group must be multiplexed. The timing of the signals between the groups is not guaranteed. This probably is not a big deal for I2C or UART, but may be an issue for SPI running at 24 MHz.

May be as technology used for typical MCUs improves, it will become a reality, but not right now
Alex
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
I would really like to see processor makers make a totally capable pin mux so you can put anything anywhere. it doesn't cost that much logic.
It unfortunately does. Newer Atmel/Microchip MCUs have pretty flexible multiplexing (but not any to any). And for smaller devices all multiplexing options are available. But for bigger devices (like SAM E54) SERCOM unit (UART/I2C/SPI) pins are assigned in groups, and the whole group must be multiplexed. The timing of the signals between the groups is not guaranteed. This probably is not a big deal for I2C or UART, but may be an issue for SPI running at 24 MHz.

May be as technology used for typical MCUs improves, it will become a reality, but not right now

They do it on fpga's without problems. All that is required is is a pass gate (basically an 'analog switch' made from a fet)

Let's assume 32 signals. Since it is 1 out of many you only need 5 control bits. So 5 flipflops. If you make a ladder mux you don't need a decoder so you are looking at 62 transistors .
You chain the control flipflops in a long shift register. At reset the configuration gets 'shifted in' and done . The pass gates do not add any delay as it is not a logic gate , only an in-line switch.

so for 32 signals you need 32 x (62 fets + 5 flipflops )

That amount of transistors is nothing compared to what is already on the chip.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11720
  • Country: us
    • Personal site
Overall FPGA and MCU design is different. It is not about actual multiplexing, that's really easy. But you now have to route each peripheral output to every pad. This is a lot of routing. In FPGA this happens naturally, but not in the MCU with fixed peripherals. 

A single shift register may not work as well, since MCU applications may want to control the assignment in run-time. Of course you may be able to accept this limitation.
Alex
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4700
  • Country: au
  • Question Everything... Except This Statement
In reality you can simplify your routing, for just about everything you do not need the mux anywhere near the I/O pins that see high current, its better to attack it near the registers.  after all they are a hardware register that controls the pins at max clock frequency so you have your muxing back there for everything that is just a combo of input / output / pullup, you would swap all 3 (or more) registers bits that control a given pin to a different pin

I obviously am only an armchair warrior when it comes to silicon layout, but I would assume this approach even if used without the muxing would reduce the amount of routing by not needing the peripheral control lines near the pins, seeing as they already run there for I/O

The analog stuff.. well I love the ATtiny1634, because it just made every bloody pin an ADC pin. and equally every pin able to use the analog comparitor.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4684
  • Country: dk
wait till you start playing with FPGA's.
Do the layout first. then assign pins.

I would really like to see processor makers make a totally capable pin mux so you can put anything anywhere. it doesn't cost that much logic.
Only power , crystal and reset pin should be 'hard'. The rest should be programmable. ( with the exception of USB )
Programming should be done using bootloaders over usb  or over 2 pins that change operation (tx/rx or sclk / sdio ) ( only when reset is physically held down longer than 3 seconds. The loader kicks in)

don't do the layout before you have tried pinout in the fpga tool, there are some limitation to pin placement. from something as simple as what bank voltages are compatible with
what io standards, sometimes depending on whether you need internal termination. And if you use things like serdes certain pins often pair up certain clk pins

 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2794
  • Country: ca
wait till you start playing with FPGA's.
Do the layout first. then assign pins.
This is a recipe for a board respin. Always validate your pin assignment in FPGA toolchain before you commit to any layout and manufacture the board! There is a number of limitations for pin assignments, especially for high-speed interfaces, when you simply won't be able to close timing no matter what you do if you choose wrong pins.

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8750
  • Country: fi
All of this is very easy if you mostly use the pins as GPIO. If you need, for example, an SPI, then you have to be aware of which pins can support the SPI. If you need, say, UART at the same time, you need to solve the puzzle if they share pins.

See attached, I start by adding all relevant peripheral mapping possibilities to the schematic symbol.

I like to work without the manufacturer's "tool of the year". This doesn't apply to FPGA designs: with them, using the manufacturer-supplied pin mapper is an essential part of PCB layout.

 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10212
  • Country: nz
If using the ATMega328p watch out for the ADC only pins.
Although it's less of an issue now, since there's the ATMega328pb
Greek letter 'Psi' (not Pounds per Square Inch)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf