Upon receiving the board, I started by getting the typical Hello World program to work (i.e. getting LEDs to light up). Of the 2 methods that can be used to toggle a pin which are 1. Directly writing values to TRISDX and RDX and 2. Using the PLIB Library which is provided by Harmony, Dr. Shawn thought about the pros and cons of both methods and decided to make our lives easier by going with the PLIB Library method which provides the benefit of abstraction and passing the pin number as a variable, with a trade-off of having a minimal overhead which was still acceptable. With that, I proceeded with getting all 3 LEDs to blink using a simple while loop as a timer, albeit an inaccurate one for now.
Then came the RTOS. Armed with the knowledge of semaphores and mutexes, I set up 3 tasks with each of them controlling its own LED which were then kept in sync by the usage of a single mutex hence allowing the LEDs to blink in a successive pattern. The timer issue was also solved by using FreeRTOS’s built-in delay functions. Happy with my results, I added another 3 tasks to control each button which were used to change the blinking patterns of the LEDs.
Following that, the TCPIP stack came next. However, this was not as easy as before as it required some configuration in the Harmony Configurator. I wasted some time trying to find the right subset of settings before realising that I either did not set the correct driver to be used or had to disable some obscure debugging setting before the TCPIP stack started to work.
At this point, I should be getting the USB functions to work. But alas, the kid in me got the better of me so I decided to combine the 3 LED blinking tasks with the 3 button tasks + 1 TCPIP monitoring task which are used as controls for the blinking patterns of the LEDs. Now this broke the entire application. With 7 tasks running consecutively with the system task, TCPIP service task, and some weird timer task running in the background, I discovered that it could be due to the total task stack sizes exceeding some limit. I then reduced the stack size allocated for each task which then allowed the application to run. However, this was not without fail when the LEDs stopped blinking after some time for no apparent reason. I initially thought it was something to do with the wrong timer configuration until I discovered that I did not allocate an adequate stack size for the TCPIP service task and TCPIP monitoring task which crashed the application somewhere between the point where it is allocated an IP Address to the point where it establishes a TCPIP packet. Fine tuning all stack sizes for each task finally got the job done.
I then started work on the USB functions. Currently the device is able to output a string of characters but I intend to stay on a little longer with the starter kit and tweaking the USB functions before moving on to the real board.