Output Mapping

boutzo

New Member
How can you assign numbers to output pins and put them into a eeprom table for multiplexing leds as in Buzby's orrey project. I understand everything else except how to remap B.0 to 0 B.1 to 1 ect...

or is it just understood that 0-7 = pinsB 8-15 = pinsC 16-23 = pinsA 24-31 = pinsD

Planning on using 28x2 for a 30 led multiplexed bargraph
 
Last edited:

hippy

Technical Support
Staff member
Yes, 0-7 = pinsB, 8-15 = pinsC, 16-23 = pinsA, 24-31 = pinsD, is correct.
 

Goeytex

Senior Member
PortB = 0 to 7

PortC = 8 to 15

PortA = 16 to 23

PortD = 24 to 31


This code may be useful to demonstrate the Pin Constants. Run in the PE6 Simulator on on a real chip.

Code:
[color=Navy]#picaxe [/color][color=Black]28X2[/color]
[color=Navy]#No_Table[/color]

[color=Blue]Symbol [/color][color=Purple]Pin_Constant [/color][color=DarkCyan]= [/color][color=Purple]B0[/color]

[color=Blue]Sertxd ([/color][color=Red]"PortB Pins"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
for [/color][color=Purple]Pin_constant [/color][color=DarkCyan]= [/color][color=Blue]B.0 to B.7
   Sertxd ([/color][color=Black]#[/color][color=Purple]Pin_Constant[/color][color=Black],[/color][color=Red]"  "[/color][color=Blue])
next
Sertxd (cr[/color][color=Black],[/color][color=Blue]lf[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)

Sertxd ([/color][color=Red]"PortC Pins"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
for [/color][color=Purple]Pin_constant [/color][color=DarkCyan]= [/color][color=Blue]C.0 to C.7
  Sertxd ([/color][color=Black]#[/color][color=Purple]Pin_Constant[/color][color=Black],[/color][color=Red]"  "[/color][color=Blue])
next
Sertxd (cr[/color][color=Black],[/color][color=Blue]lf[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)

Sertxd ([/color][color=Red]"PortA Pins"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
for [/color][color=Purple]Pin_constant [/color][color=DarkCyan]= [/color][color=Blue]A.0 to A.7
  Sertxd ([/color][color=Black]#[/color][color=Purple]Pin_Constant[/color][color=Black],[/color][color=Red]"  "[/color][color=Blue])
next
Sertxd (cr[/color][color=Black],[/color][color=Blue]lf[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
 
Sertxd ([/color][color=Red]"PortD Pins"[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf) 
for [/color][color=Purple]Pin_constant [/color][color=DarkCyan]= [/color][color=Blue]D.0 to D.7
  Sertxd ([/color][color=Black]#[/color][color=Purple]Pin_Constant[/color][color=Black],[/color][color=Red]"  "[/color][color=Blue])
next
Sertxd (cr[/color][color=Black],[/color][color=Blue]lf[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)

Stop[/color]
 
Last edited:

westaust55

Moderator
My take on the PICAXE pre-defined IO pin allocation sequence is:
For the early PICAXE chips most pins were defined as inputs only or outputs only (there are some exceptions such as the 8 pin devices, some pins on 14 pin devices and some pins on the 28 pin devices).

In general the Port RB on the native PIC chips was assigned as outputs and 0 to 7 was sufficient to control them.

For the early 28 and 40 pin PICAXE devices the native PIC port RA pins were defined as PortA for Analog inputs. Only Port A (and RE pins on 40 pin chips) had Analog capability.

Thus native PIC port RC as the remaining port on the PIC chips was generally used for the inputs – as inputs only or in some cases they could be bidirectional.
With the move to the Port.Pin nomenclature, by keeping PIC port RB as PICAXE PortB using the predefined values 0 to 7 this would mean that programs from earlier chips would work with minimal changes (just include a DIRSB command).
 

hippy

Technical Support
Staff member
As I recall it; the 18-pin devices had an input and output port, which suggests A and B to match the underlying PICmicro port names, but the 28-pin devices had already used PORTA terminology for the analogue pins when used as digital, so to avoid confusion B and C were chosen. PORTC had also been used for the in/out port of the 28X1 making B for the default output port a logical choice, and fitted with B being the underlying PICmicro port B on the 18-pin and 28-pin devices.

To make numbering consistent, all parts ( except 08M2 ) have B and C, so number those first, then A for the 28-pin, then D for the 40-pin.

8-pin = B or C
14, 18, 20-pin = B and C
28-pin = B, C and A
40-pin = B, C, A and D
 
Top