Lab 3: Move Application into an RTOS

Step 6: Modify the Temperature Sensor and SDCARD Application

The application is already developed and is available in the following files.

  • app_sdcard.c
  • app_sdcard.h
  • app_sensor.c
  • app_sensor.h

They are available under
<your unzipped folder path>\getting_started_pic32_wfi32e\Lab3\dev_files.

The application file contains the application logic. It also contains placeholders that you will populate with the necessary code.

1

Go to the <your unzipped folder path>\getting_started_pic32_wfi32e\Lab3\dev_files folder and copy the following pre-developed files:

  • app_sdcard.c
  • app_sdcard.h
  • app_sensor.c
  • app_sensor.h

Paste and replace (overwrite) your project files in <your harmony 3 project folder path>\PIC32_WFI32E\firmware\src with the copied files.

To simplify the development of Lab 3, the files app_sensor.c and app_sdcard.c have already been modified. The usage of the functions SYS_DEBUG_PRINT() and SYS_DEBUG_MESSAGE() has been replaced by the function APP_PRINT_STRING().

Tip: Search for the string "Step #" in the target file to locate the position where you are supposed to write the code.

2

Open app_sensor.c in MPLAB X IDE.

  • Verify that all calls to SYS_DEBUG_PRINT() and SYS_DEBUG_MESSAGE() have been replaced by the function APP_PRINT_STRING().

3

Open app_sdcard.c.

  • Verify that all calls to SYS_DEBUG_PRINT() and SYS_DEBUG_MESSAGE() have been replaced by the function APP_PRINT_STRING().
  • Follow the steps below.

1

Search for "Step #1":

  • Create a queue using the FreeRTOS function xQueueCreate(uxQueueLength, uxItemSize), capable of containing one float value.
    • uxQueueLength is the size of the queue. Use the pre-defined macro APP_SDCARD_QUEUE_SIZE (for this queue, the size is one).
    • uxItemSize is the item size in the queue. Use the pre-defined macro APP_SDCARD_QUEUE_ITEM_SIZE (for this queue, it is the size of a float).
    • This function returns the reference of the queue. Use SDcardQueueHandle to store the handler.

2

Scroll-up and Search for "Step #2":

  • Modify the function APP_SDCARD_Notify() to write the temperature value (float) into the queue.
  • Use the FreeRTOS function xQueueOverwrite(xQueue, pvItemToQueue).
    • xQueue is the handle of the current queue. Use SDcardQueueHandle.
    • pvItemToQueue is the item to add into the queue. Use &temperature.
    • The function returns pdTRUE if it succeeds.

3

Search for "#Step 3" and observe the code already implemented in the state APP_SDCARD_STATE_IDLE.

  • The FreeRTOS function uxQueueMessagesWaiting() is used to monitor the number of items loaded into the queue.
  • The FreeRTOS function xQueueReceive() will read the data placed into the queue.



Next Step >

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.