Verifying PIC24EP Clock Frequency by UART Module

So the complete UART1 ISR is implemented as follows

 RPINR18bits.U1RXR = 43;  // U1RX to RP43
 RPOR4bits.RP42R = 1;     // U1TX to RP42

A couple of points worth mentioning.

  • In order for the program to work correctly, the data read from URXDA must be cleaned up by zeroing the upper 8-bit part. Then the characters are converted to upper case. This simplifies command interpreation.
  • Receiving characters are pushed into a global buffer INB. While doing so, the ISR checks whether a string of “TON” or “TOFF” is found. If that is the case, timer 1 is turned on or off by setting _T1IE = 1 or _T1IE = 0, respectively, where _T1IE represents interrrupt enable bit of timer 1. A text response is transmitted to host using PutStrU1( ) function.
  • Whenever a user presses [Enter], a response “Ready” is sent.
  • As a C programmer should always beware, never write beyond the allocated buffer size.
  • Do not forget to clear interrupt flag before leaving the ISR.

For your convenience, the complete C source file for this example can be downloaded here.

uart_ main.c

As shown in the video below, UART communication is established successfully at 115200 bps. Timer 1 can be controlled via TON and TOFF commands as desired. This result also verifies that PIC24E is indeed running at 70 MIPS.

The experiment was captured using a webcam included with my monitor. Sorry for the poor quality. I just want to show it alongside the messages in terminal program.



Comments are closed.