PIC24FJ tiny remappable pin library




The PIC24FJ microcontroller family feature lots of modules to perform many common operations with hardware. The problem with is is the microcontroller needs a big enough pinout for all of them.
Because this is not possible, the PIC23FJ feature remappable pins (RP) which can be assigned to different modules. How to use this function is no secret, and perfectly explained in the user reference manual. Yet I wanted to share the tiny library I have put together to handle them. The library does only cover a few modules, but can easily be modified to cover them all.

I²C Master driver for PIC24FJ + FreeRTOS


I have written an I²C driver for my PIC24FJ32GB002 which is running with FreeRTOS. It has an easy to use API and can be easily adapted to suit any other microcontroller. Also, thanks to the RTOS, many independent threads can be queued to access the I²C bus.

Another great feature is that when a thread is performing an I²C communication, which is really slow, it blocks letting another thread use the CPU. Yet this feature is currently disabled in my driver because at 400 kHz I²C speed it took the PIC24FJ32GB002 more time to dispatch a thread than to wait for the communications to end. Thus it is only useful for 100 kHz communications or for faster microcontrollers.

For simplicities sake, the driver does only detect and report comunication errors, but does no handle them. It is up to the user to do this.

I have been using this code for a while, and I am fairly pleased whith it. Yet there could still remain some hidden bugs or optimization possibilities. Any feedback is highly welcome.