I am trying to bit banging an UART Port using PIC32MX with timer5 (the only available at this time) but I am struggling how to configure the timer for a Baud Rate of 115200bps. I don't want a flow control not even to deal with parity bit. If possible can someone explain me on a Step-by-step procedure?
My Definitions are:
#define GetSystemClock() 48000000UL // System clock frequency (Hz) #define GetPeripheralClock() 48000000UL // Peripheral clock frequency #define GetInstructionClock() (GetSystemClock()) // Instruction clock frequency #define MILLISECONDS_PER_TICK 10 // Definition for use with a tick timer #define TIMER_PRESCALER TIMER_PRESCALER_8 // Definition for use with a tick timer #define TIMER_PERIOD 37500 // Definition for use with a tick timer #define SYS_FREQ 40000000UL #pragma config FPLLMUL = MUL_20 // PLL Multiplier #pragma config FPLLIDIV = DIV_1 // PLL Input Divider #pragma config FNOSC = FRC // Oscillator Selection #pragma config POSCMOD = EC // Primary Oscillator #pragma config FPLLODIV = DIV_2 // PLL Output Divider #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor #pragma config FWDTEN = OFF // Watchdog Timer (controlled by software) #pragma config WDTPS = PS65536 // Watchdog Timer Postscale 1048s #pragma config FCKSM = CSECMD // Clock Switching Enable & Fail Safe Clock Monitor Disable #pragma config OSCIOFNC = OFF // CLKO Disable #pragma config IESO = ON // Internal/External Switch-over #pragma config FSOSCEN = ON // Secondary Oscillator (KLO was off) void initTIMER5( void ){ // Initialize Timer 5 T5CON = 0x0; TMR5 = 0; T5CONbits.TCKPS = 0b111;//1:256 prescale value IFS0bits.T5IF = 0; IPC2bits.T2IS = 0; IPC2bits.T5IP = 2; IEC0bits.T5IE = 1; T5CONSET = 0x8000; } By now I think I just need to configure the T5CONbits.TCKPS and the PR5 register in order to synchronize with the baud rate, right?
I really need your help on this guys.
