i new mplab x harmony framework , in working microcontrollers. working on pic32mz2048ech144. wanted transmit simple string using usart , see displayed in realterm terminal.(i have tried hyperterminal also.) whatever string send, see junk characters being displayed. when browsed solution problem of junk characters being displayed, there suggestions check baud rate. have set baud rate 9600 in mplab harmony configurator(options -> harmony framework configuration -> drivers -> usart -> usart driver instance 0 -> baud rate -> 9600). used following line in app.c explicitly set baud rate.(pbclk 100mhz). no luck! plib_usart_baudrateset(usart_id_2, 100000000 ,9600); code app.c file:
/******************************************************************************* start of file */ const char *string1 = "*** uart interrupt-driven application example ***\r\n"; const char *string2 = "*** type characters , observe led turn on ***\r\n"; app_data appdata = { }; app_drv_objects appdrvobject; void app_initialize ( void ) { appdata.state = usart_enable; appdata.interruptflag = false; } bool writestring(void) { if(*appdata.stringpointer == '\0') { return true; } while (plib_usart_transmitterisempty(usart_id_1)) { plib_usart_transmitterbytesend(usart_id_1, *appdata.stringpointer); appdata.stringpointer++; if(*appdata.stringpointer == '\0') { return true; } } return false; } bool putcharacter(const char character) { if(plib_usart_transmitterisempty(usart_id_1)) { plib_usart_transmitterbytesend(usart_id_1, character); return true; } else return false; } void app_tasks ( void ) { /* check application state*/ switch ( appdata.state ) { case usart_enable: /* enable uart module*/ plib_usart_baudrateset(usart_id_1, 100000000 ,9600); plib_usart_enable(usart_id_1); appdata.stringpointer = string1; appdata.state = usart_transmit_first_string; break; case usart_transmit_first_string: if(true == writestring()) { appdata.state = usart_transmit_second_string; appdata.stringpointer = string2; } break; case usart_transmit_second_string: if(true == writestring()) { appdata.state = usart_receive_done; } break; case usart_receive_done: if (appdata.interruptflag) { if(true == putcharacter(appdata.data)) { appdata.interruptflag = false; } } break; default: while (1); } } /******************************************************************************* end of file */
i sorry cannot attach image of output receive in realterm not have enough points. have no clue else problem gives mismatch of baud rate. hints or of great help. in advance. kindly apologize me mistakes in post.
you correct baud rate, sure how usart hooked computer? have translator chip since computer expecting +-5v? baud, check clocking scheme , know pbclk div_2 of sysclock. there great clocking schematic in harmony framework double check clocking , config pragmas.