PIC32 PLIB_UART Beginner's Struggle

PIC32 PLIB_UART Beginner's Struggle

Postby iTomov22 » Wed Mar 08, 2023 10:49 pm

Hey guys,
I'm currently developing a PIC32-based project for my thesis and so I bought the DT100113 PIC32MK MCJ Curiosity Pro development board with PKoB4.
It has a PIC32MK0512MCJ064 on-board. The reason I chose this particular PIC is for the QEI interfaces. My project will do the following: Read a quadrature encoder (attached to AC servo motor),
read a 4-20 mA current via (MikroE 4-20 R click board via SPI) and intention is to report the data via UART to the computer in a simple protocol i.e. <POSITION|CURRENT>.
The string will contatin '<' (opening character); POSITION (pos. value);'|'(delimiter character); CURRENT (current value) and '>' closing character.
My aim is yo send the data via the PKoB4 or other UART to USB converter (like FTDI board) to an application I wrote. The string will be parsed and graphically visualized on the PC.

I'm at the very beginning. I read in the datasheet, MCC manual, etc. and was able to create a project in MPLAB X, configure the UART1 and UART2 interfaces and got to the point where I try to send some string over the UART.

I am using solely the PLIB_UART1.h library as generated by the MCC.

Here is my current code:

Code: Select all
#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "definitions.h"                // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

       
int main ( void )
{
    /* Initialize all modules */
    SYS_Initialize ( NULL );
       
        char outMsg1[] = "Hello, World - Line 1 on UART1.\r\n";
        char outMsg2[] = "Hello, World - Line 2 on UART1.\r\n";
        char outMsg3[] = "Hello, World - Line 1 on UART2.\r\n";
       
        UART1_Write(&outMsg1[0], sizeof(outMsg1));
        UART1_Write(&outMsg2[0], sizeof(outMsg2));
        UART2_Write(&outMsg3[0], sizeof(outMsg3));
   
    while ( true )
    { 
           
    }

    /* Execution should not come here during normal operation */
   
    return ( EXIT_FAILURE );
}


And here I have two problems.
1. Problem 1: When I push the reset button, on UART1 I see only first line printed (outMsg1). outMsg2 is completely missing, like it's not in the code.
2. Problem 2: In the UART2 terminal window - I receive gibberish.
[img]
https://ibb.co/GxcGXmQ
[/img]

And here are my settings:
[img]
https://ibb.co/gzQ6zvB
[/img]

[img]
https://ibb.co/JrNqPtF
[/img]

Any guidance on where to read thoroughly how to properly use the method UARTx_Write() will be highly appreciated.
Thank you in advance!

Cheers,
Iliyan
iTomov22
 
Posts: 1
Joined: Wed Mar 08, 2023 10:28 pm

Return to SCI/USART/EUSART

Who is online

Users browsing this forum: No registered users and 1 guest

cron