PIC pin layout - How come they're not consecutive?

Thread Starter

Robin66

Joined Jan 5, 2016
275
Hi, quick question out of interest more than anything else. I'm designing a board incorporating PIC24FV32KA304 and I've noticed that the port pins are separated out around the IC. My code benefits if I can have the 6 controls of a 3-phase bridge on the same port. To my surprise I'm struggling to find 6 pins of the same port adjacent to each other. Is there a good reason why the layout is such? Perhaps there's a benefit of this that I'm missing? I'm upgrading from a PIC18F2620 (28 pin, SOIC) where the port pins are indeed adjacent to each other

eg . RC0-2 are on the RH side, RC3-5 are on the top, RC6-9 are on the LH side.
pic24FV.PNG
 

jpanhalt

Joined Jan 18, 2008
11,088
Hi, quick question out of interest more than anything else. I'm designing a board incorporating PIC24FV32KA304 and I've noticed that the port pins are separated out around the IC. My code benefits if I can have the 6 controls of a 3-phase bridge on the same port. To my surprise I'm struggling to find 6 pins of the same port adjacent to each other. Is there a good reason why the layout is such? Perhaps there's a benefit of this that I'm missing? I'm upgrading from a PIC18F2620 (28 pin, SOIC) where the port pins are indeed adjacent to each other
Why do you need the port pins to be physically adjacent?

Pins of the same port are often not adjacent even in the mid-range devices. In some cases, I have found that to be an advantage for routing. Never really bothered me, but I assumed it was related to the die structure and/or compatibility with other devices of the same series.

John
 

Thread Starter

Robin66

Joined Jan 5, 2016
275
Thx for your reply John.

I'd like to use a single port for my 3-phase bridge control because it makes the code simpler and faster. I'd like to use an IR2330 chip for the bridge FET driver so it'd be better for my layout if the connections between PIC24 and IR2330 aren't criss-crossing other connections. Also I'm going to hook up a LCD 784450 module so having D0-7 on the same port would be advantanguous and D0-7 are consecutive on almost all LCD modules.

Yes I would have assumed die structure as a reason, but then the PIC18F I was using did have the ports laid out consecutively
 

crutschow

Joined Mar 14, 2008
27,890
It depends upon the layout designer for the chip.
They lay out the chip so that the internal structures occupy the least area and with minimum interconnect, leaving the I/O pins to be adjacent to their respective circuitry on the chip, wherever that may be.
 

NorthGuy

Joined Jun 28, 2014
611
Why don't you want to use a PIC which has hardware PWM modules? This way, the CPU can do other things while the hardware does driving. There are some PICs which have nice hardware modules suitable to drive bridges. For example, PIC16F157x or PIC16F177x on the low end, or dsPIC33 GS series on the higher end.
 

Thread Starter

Robin66

Joined Jan 5, 2016
275
it is trivial to remap those pins.
So in your mind there's no disadvantage at all having the ports spread around the board? Maybe I'm missing something. If I wanted to transfer a char to an LCD module and PORTA was on consecutive pins I could wire PORTA0-7 to D0-7 and execute (1 instruction)
Code:
movff mychar, PORTA
How would you do the same if D0-7 was mapped to a random selection of pins on PORTA-PORTC? The only way I know of involves a lot of conditional branching and masks, ~50 instructions worth
 

Thread Starter

Robin66

Joined Jan 5, 2016
275
Why don't you want to use a PIC which has hardware PWM modules? This way, the CPU can do other things while the hardware does driving. There are some PICs which have nice hardware modules suitable to drive bridges. For example, PIC16F157x or PIC16F177x on the low end, or dsPIC33 GS series on the higher end.
Thx for the tip NorthGuy. So far I've been using CCP1 and CCP2 driven from TMR1 to implement the PWM, TMR2 to drive a boost converter, and TMR0 to do LCD update. I didn't know hardware PWM modules existed. I'll look into the chips you suggest now and see how this would improve the situation.

One of the most limiting factors in my code is the cost of divide operations. I'm looking forward to seeing the perf of the hardware divider on the PIC24F
 

jpanhalt

Joined Jan 18, 2008
11,088
I think you are confusing the physical pin locations of a port with the electronic connections. PORTA<0-7> are consecutive electronically. It doesn't matter where the little "legs" are located on the epoxy chip.

John
 

Thread Starter

Robin66

Joined Jan 5, 2016
275
I think you are confusing the physical pin locations of a port with the electronic connections. PORTA<0-7> are consecutive electronically. It doesn't matter where the little "legs" are located on the epoxy chip.

John
Does it not impact the pcb routing at all? Naturally I prefer a layout where the routes are as short as possible with minimal vias. This seems more difficult to achieve in a situation where electronically the port is consecutive but physically it is not. Either the layout has to handle this, or the code does. I don't see another way round this
 

jpanhalt

Joined Jan 18, 2008
11,088
The layout handles it. The layout is trivial. More directly to your point, as I mentioned, sometimes non-adjacent pins of the same port make layout easier or at least not significanlty harder.

John
 

Thread Starter

Robin66

Joined Jan 5, 2016
275
The layout handles it. The layout is trivial. More directly to your point, as I mentioned, sometimes non-adjacent pins of the same port make layout easier or at least not significanlty harder.

John
I must be missing something. As an example, I'll probably use RB10-15 for the 3 phase bridge because these are fairly close together on the PIC24F pic above. RA10-11 are enclosed by this layout, however I can approach them from the other side of the board and use 2 vias. What would your suggestion to be drive D0-7? If I use RC0-7, how do I layout my pcb to converge these pins without cutting off the many enclosed pins eg. RA2-3, RA8, RB4, RA4, RA9... ?
 

dannyf

Joined Sep 13, 2015
2,197
So in your mind there's no disadvantage at all having the ports spread around the board?
it couldn't be further from the truth. any approach will have its pros and cons. your approach for example has the decided advantaging of simplicity, at the expense of needing consecutive pins and needing all pins.

your job isn't to find an approach that has no disadvantage; but to find an approach that has a favorable compromise of its advantages and disadvantages for your particular application.
 

Thread Starter

Robin66

Joined Jan 5, 2016
275
it couldn't be further from the truth. any approach will have its pros and cons. your approach for example has the decided advantaging of simplicity, at the expense of needing consecutive pins and needing all pins.

your job isn't to find an approach that has no disadvantage; but to find an approach that has a favorable compromise of its advantages and disadvantages for your particular application.
Ok, so I'm not missing a substantive code trick then. I suspect I'm not missing a layout trick either. I think I'll end up working round this in code as I did on v1 of my board after I'd already fabricated the board without trying to use the same port for D0-7. Now that's not an option because I've upgraded my chip I'll maintain the slow code.
 
Top