I'm using harmony for my project and I'm not able to print via the printf function. I'm using UART1 and i have been reading that the standard print channel is UART2. Can someone help me how to redirect to my UART1 channel. Using the U1TXREG then it's possible to send 1 character to my serial port. I'm using internal clock 8MHz. Except for setting up the uart with PPS (U1RXR = 03, RPB3R = 01 and setting the specific rx pin to input all settings remained as setup via harmony. Thanks in advance for your help. Below the main routine..
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
#include <stddef.h> // Defines NULL
#include <stdbool.h> // Defines true
#include <stdlib.h> // Defines EXIT_FAILURE
#include <cstdio> // for print instruction
#include "definitions.h" // SYS function prototypes
#define SYS_FREQ 8000000 // Running at 8MHz
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
void TimerCallBack(uint32_t status, uintptr_t context)
{
PORTAbits.RA4 = !PORTAbits.RA4;
}
void delay_us(unsigned int us)
{
// Convert microseconds us into how many clock ticks it will take
us *= SYS_FREQ / 1000000 / 2; // Core Timer updates every 2 ticks
_CP0_SET_COUNT(0); // Set Core Timer count to 0
while (us > _CP0_GET_COUNT()); // Wait until Core Timer count reaches the number we calculated earlier
}
void delay_ms(int ms)
{
delay_us(ms * 1000);
}
void _mon_putc (char c)
{
while (U1STAbits.UTXBF); // Wait til current transmission is complete
U1TXREG = c;
}
int main (void)
{
/*
ANSELA = 0x00;
LATA = 0x0; // Initial Latch Value
TRISA = 0x00; // All PORTA pins are output
ANSELB = 0x00;
LATB = 0x0; Initial Latch Value
TRISB = 0x00; Direction Control
*/
/* Initialize all modules */
SYS_Initialize ( NULL );
TMR2_CallbackRegister(TimerCallBack, 0);
TMR2_Start();
char Test = 'P';
while(1)
{
U1TXREG = Test;
//setbuf(stdout, NULL);
//printf("counter%d\n",0);
PORTBbits.RB4 = !PORTBbits.RB4;
delay_ms(500);
PORTBbits.RB4 = !PORTBbits.RB4;
delay_ms(500);
}
}
/*******************************************************************************
End of File
*/