chipKIT® Development Platform

Inspired by Arduino™

How to use FTDI FT232R USB serial converter in Max32

Created Thu, 23 Feb 2012 10:01:04 +0000 by EratC


Thu, 23 Feb 2012 10:01:04 +0000

My system: Micro controller: PIC32 (pic32mx795f512l) Debugger: Pickit3 Expansion board: Digilent Chipkit Max32 Using MPLAB IDE v8.83

I am trying to modify and use the example code given with the PIC32MX UART Peripheral Library to be able to use the FTDI FT232R USB serial converter. According to the max32 reference manual, I have to use the UART1A (U1ARX,U1ATX) in the PIC32 microcontroller. However, when I try to modify the example code "uart_interrupt" to use UART1A, I get an error that UART1A is not declared. I read somewhere in this forum that UART1A is named as UART1. So I changed all the configuration to UART1.

Here is my code: -------BEGIN CODE-------------

#include #define GetSystemClock() (80000000ul) #define GetPeripheralClock() (40000000ul) #define GetInstructionClock() (GetSystemClock()/2) #define DESIRED_BAUDRATE (9600) //The desired BaudRate

int main(void) {



if(UARTTransmitterIsReady(UART1)) { UARTSendDataByte(UART1,0x55); } } }

-------END CODE---------------

But the U1TXREG remains 0 all the time. Can someone point me to the right direction and show me what I am doing wrong? I will appreciate it very much. Thank You

Ryan K

Sat, 25 Feb 2012 02:55:57 +0000


I assume you're including plib.h and p32xxxx.h and any other necessary headers and setting the config bits? I would check your U1CON and U1STA registers to make sure they are behaving properly when you run your code. I personally much rather modify the registers directly than use Microchip's API calls.

e.g. #define bnOn 15 //You can define all the other bits of the UxCON register #define bnTrmt 8 //You can define all the other bits of the UxSTA register #define pbclk 40000000 #define baudUart1 2400 #define brgUart1 ( pbclk / ( 16 * baudUart1 ) ) - 1

int main(void) { U1CON = 0; U1BRG = brgUart1; U1CON = (1 << bnOn);

while(1) { if(U1STA & (1 << bnTrmt)) U1TXREG = 0x55; } }

Use this data sheet to help you out I didn't compile this or anything so sorry if there is something I'm missing but you get my general point. I find this way to be easier to code and debug but to each their own :) .