Electronics > Projects, Designs, and Technical Stuff

I/O config for PIC24F series

(1/4) > >>

osmosis321:
Who here would like to earn my eternal gratitude by giving me the lowdown on setting up the PIC24F peripheral multiplexing?

I'm trying to use I2C1 and UART1, and in both cases the outputs aren't working, I believe it's because I'm not setting up PPS properly or not configuring the TRIS bits properly, or maybe the peripheral is being overridden by a higher priority peripheral?

It's all so confusing, and I'm all so desperate to find the answer.

migsantiago:
I can help.

Show your current code, the PIC24 you're using, the compiler you're using, the module configurations you are looking for... and then... I might help.

Neb:
I've used those PICs a lot, so i'll see if i can help.

I think configuring the peripheral overwrites the TRIS setting, but i usually set the TRIS to the direction of the pin anyway (eg set UART Tx to output).

To configure the UART Tx, you need to find the peripheral function number (U1TX is function 3) and assign it to a pin:
        RPOR2bits.RP4R = 3;      // Make Pin RP4 U1TX

To configure the UART Rx, the syntax is reversed, so you assign function U1RX to pin RP5.  Note, the register name (RPINR18) means register 18, not pin 18.
        RPINR18bits.U1RXR = 5;   // Make Pin RP5 U1RX

Also, the PIC24FJ64GA... I2C1 has a brutal errata (check your chip's errata document) where it will not initialize unless you use another pin to pull SDA low first.  But I2C2 should work properly.

I found some decent I2C driver source code on the microchip website, but you will likely have to go through it to fix some of their bugs (iirc one of their control flags was backwards and caused a lockup) and configure it properly.

johnmx:
I2C module is not currently included in the peripheral pin select feature.

Mechatrommer:
what pic24f? maybe i will have a look at the documentation if i have a time or when this thread is rebumped.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version