PIC32MZ-serial.h 583 B

12345678910111213141516171819202122232425262728
  1. void _mon_putc(char c);
  2. static void init_serial() {
  3. #ifdef MICROCHIP_PIC32
  4. #if defined (__32MZ2048ECH144__) || (__32MZ2048ECM144__)
  5. /* Set up PB2 divisor for UART2 */
  6. SYSKEY = 0x00000000;
  7. SYSKEY = 0xAA996655;
  8. SYSKEY = 0x556699AA;
  9. PB2DIV = 0x00008018;
  10. SYSKEY = 0x33333333;
  11. /* UART2 Init */
  12. // U2BRG = 0x0C;
  13. U2BRG = 0x7;
  14. ANSELBCLR = 0x4000;
  15. ANSELGCLR = 0x0040;
  16. RPB14R = 0x02;
  17. U2RXR = 0x01;
  18. U2MODE = 0x8000;
  19. U2STA = 0x400;
  20. #elif defined __PIC32MX__
  21. SYSTEMConfigPerformance(80000000);
  22. DBINIT();
  23. #endif
  24. #endif
  25. }