Datasheet
PIC24FJ64GA104 FAMILY
DS39951C-page 128 2010 Microchip Technology Inc.
EXAMPLE 10-2: CONFIGURING UART1 INPUT AND OUTPUT FUNCTIONS IN ASSEMBLY CODE
EXAMPLE 10-3: CONFIGURING UART1 INPUT AND OUTPUT FUNCTIONS IN C
;unlock registers
push w1;
push w2;
push w3;
mov #OSCCON, w1;
mov #0x46, w2;
mov #0x57, w3;
mov.b w2, [w1];
mov.b w3, [w1];
bclr OSCCON, #6;
; Configure Input Functions (Table10-2)
; Assign U1CTS To Pin RP1, U1RX To Pin RP0
mov #0x0100, w1;
mov w1,RPINR18;
; Configure Output Functions (Table 10-3)
; Assign U1RTS To Pin RP3, U1TX To Pin RP2
mov #0x0403, w1;
mov w1, RPOR1;
;lock registers
mov #OSCCON, w1;
mov #0x46, w2;
mov #0x57, w3;
mov.b w2, [w1];
mov.b w3, [w1];
bset OSCCON, #6;
pop w3;
pop w2;
pop w1;
//unlock registers
__builtin_write_OSCCONL(OSCCON & 0xBF);
// Configure Input Functions (Table 9-1)
// Assign U1RX To Pin RP0
RPINR18bits.U1RXR = 0;
// Assign U1CTS To Pin RP1
RPINR18bits.U1CTSR = 1;
// Configure Output Functions (Table 9-2)
// Assign U1TX To Pin RP2
RPOR1bits.RP2R = 3;
// Assign U1RTS To Pin RP3
RPOR1bits.RP3R = 4;
//lock registers
__builtin_write_OSCCONL(OSCCON | 0x40);