■ SCHEMATIC 1. This looks like
any other eight-bit Microchip
PIC layout. The basics have not
changed. I/O is still I/O and a
UART is still a UART. Only the
internal program and data
memory formats have changed.
inputs that the PIC24FJ64GA002 doesn’t even have.
Although the PIC24FJ64GA002 is a 16-bit microcontroller,
it still has pieces of itself that follow the eight-bit tradition in a
16-bit way. Now that we’ve disabled the A-to-D inputs, the next
step we will take is to condition the Port B I/O pins to drive the
quartet of LEDs. This is done with the TRIS statement:
TRISB = 0x0FFF;
The TRISB C30 statement looks just like an eight-bit
TRISB C statement with eight extra bits. I/O pins RB12
through RB15 are now output pins. According to what we
see in Schematic 1, we can now turn on each individual
LED by writing a zero to the corresponding LATB bit. Piece
of cake! We didn’t do anything differently with the 16-bit
PIC24FJ64GA002 than with an eight-bit PIC except
incorporate eight extra bits into the mix.
USING THE PIC24FJ64GA002 UART
What do you think? Can we just waltz through the
UART setup just as if we were in eight-bit PIC land? Yes and
no. Take another look at Figure 1. Do you see TX and RX
assigned to any PIC24FJ64GA002 I/O pins? Nope.
No worries. Here’s where we put the PIC24FJ64GA002’s
84 November 2007
NOTE: THIS IS AN ABBREVIATED SCHEMATIC.
PLEASE CONSULT THE 16-BIT 28-PIN STARTER
DEVELOPMENT BOARD USER'S GUIDE DS51656A
FOR A FULL SCHEMATIC RENDERING.
remappable peripheral pin feature to work. The peripheral pin
select mechanism within the PIC24FJ64GA002 is used as a
peripheral force multiplier. There are only so many peripherals
that can be statically assigned to a 28-pin device such as the
PIC24FJ64GA002. The peripheral pin select feature allows the
PIC24FJ64GA002 programmer to select the peripherals
required for the project and place them on an available RPn
pin. The really cool thing about the peripheral pin select
feature is that the PIC24FJ64GA002 programmer can map
multiple peripheral inputs and outputs to multiple RPn pins.
We need to deploy our UART. The PIC24FJ64GA002
has a pair of UARTs. So, we will activate UART1. Let’s begin
by specifying the RX input for UART1. Again, we’ll work with
the cards in hand. Schematic 1 tells us that the UART1 RX
input is located on I/O pin RB9. Figure 1 tells us that pin RB9
doubles as remappable peripheral pin RP9. That leads us to
Figure 2, which maps the U1RX function to the RPINR18
(Remappable Pin Input) register. Note that the RPINR18 register is associated with UART1 only. The RPINR18 register
contains a pair of five-bit fields which we will use to map the
U1RX function to the PIC24FJ64GA002’s RB9 I/O pin. In
the case of input mapping, we need only fill in the value
representing the RPn pin we wish to map to the UART1 RX
peripheral. That value would be 9. Here’s how the C30 input
mapping statement looks: