Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

The problem I am having is with my PIC24FJ64GA002 and the UART module(s). The 24F I have is in a SPDIP28 package and it is a new B5 chip (just one under the latest B8 revision) from Microchip Direct. I have checked for errata issues which afflicted me last time with the I2C module.

Anyway, I am setting the UART1 module up as a simple transmitter. I am using PPS pin RP8 as the RX, RP9 as the TX and RP11 as the CTS pin. For now I have grounded RX and CTS as I do not need them. I have set the BRG at 115,200 (actual rate ~114,285.7, but it's close enough.) I am using the code below. I expect to see a series of bytes streaming out on RP9, but I do not. RB15 is a debug output: it pulses on each byte being sent. On RB15 I get a really slow clock, about 700 Hz, which is very low for a 115,200 baud link; I'd expect about 14 kHz.

#include <p24fj64ga002.h>

#include <uart.h>
#include <pps.h>

void init_osc()
    // Must be programmed for FRCPLL mode.
    CLKDIVbits.RCDIV = 0;

void main()
    int i = 0x55;
    // Initialize oscillator (set FRC to 8 MHz.)
    // Initialize UART1 PPS.
    // Interrupts disabled for now.
    TRISBbits.TRISB15 = 0;
        LATBbits.RB15 = 1;
        LATBbits.RB15 = 0;

I feel like I have missed something obvious, but cannot figure out what it is. If anyone has had previous experience with the UART module on 24F series devices, please let me know! I've had little luck with the Microchip forums.

share|improve this question
I just did this on the 24FJ, yesterday, as well :) .. And for your setup you will see a 115200/(8+1+1)=11.5kHz tone. –  tyblu Jan 16 '11 at 6:23
@tyblu Ah yeah... because you've got 8 bits of data, 1 start bit and 1 stop bit. –  Thomas O Jan 16 '11 at 11:47
I like to debug UARTs by sending UUUU..., which translates to 1010101010*..., giving a baud/2 square wave. (0* is stop bit, and should be slightly longer than other 0 s.) –  tyblu Jan 16 '11 at 18:42
@tyblu, Good idea. I did that too. You have to be aware though when working at high frequencies as the processor latency between loading the next byte can become a deciding factor. For example, I found at 115,200 baud my MCU could adequately produce a square wave with only a tiny bit of jitter. At 2 Mbaud, it had considerable delay between each byte and no longer resembled a square wave. –  Thomas O Jan 16 '11 at 21:44
add comment

1 Answer

up vote 2 down vote accepted

See page 110 of the data sheet.

Also, you need to disable the analogue inputs on the pins you are using.

share|improve this answer
Which datasheet? The FRM for UART, the PIC24F datasheet itself, or something else? The PIC24F datasheet has some timer documentation on 129, and the FRM only has 38 pages, am I missing something? Also, I thought that all inputs were by default digital but I will try turning them off anyway, thanks for the suggestion. –  Thomas O Jan 16 '11 at 3:48
Datasheet for the PIC24FJ64GA002 (39881D.PDF) Should be page 110. The analogue function is mentioned there. –  Leon Heller Jan 16 '11 at 3:59
Ah, turns out the problem wasn't analog inputs, but JTAG on the pins being enabled (the same as for I2C.) But it got me thinking about it being some peripheral conflict. Thanks! :) –  Thomas O Jan 16 '11 at 16:24
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.