Skip to content

Latest commit

 

History

History
108 lines (63 loc) · 7.19 KB

PIC18F57Q84_CNANO.md

File metadata and controls

108 lines (63 loc) · 7.19 KB

Using the PIC18F57Q84 Curiosity Nano Evaluation Kit as the Host MCU Board

Setting Up the Actual Embedded Firmware Example

Now that we've successfully run Python scripts on a PC to emulate all of the necessary transactions of an IoT device, we can now run a "real" embedded firmware example that's programmed onto the PIC18F57Q84 Curiosity Nano Evaluation Kit as the Host MCU board.

  1. Power cycle the AnyCloud™ serial bridge board and then hit the board's RESET (or MCLR) button
    • WFI32-IoT Development Board: RESET
    • PIC32 WFI32E Curiosity Board: MCLR

  1. Replace the USB-to-UART converter connection with the PIC18F57Q84 Curiosity Nano Evaluation Kit based on whether you're using the WFI32-IoT or PIC32 WFI32E Curiosity development board as the AnyCloud™ serial bridge (make sure to follow the correct diagram for your board)

  2. Connect the PIC18F57Q84 Curiosity Nano Evaluation Kit to the PC using the supplied micro-USB cable. Launch a Terminal Emulator program of your choice and connect to the PIC18F57Q84 Curiosity Nano Evaluation Kit's Virtual COM Port at 115200 baud.

    • Windows: The correct one to select will most likely be the one that shows up as a generic "USB Serial Port"

    • MacOS: The correct one to select will most likely be the one that is shorter in length and does not contain the RYN characters

  3. Launch the MPLAB X IDE (this tool should have been previously installed and most likely resides in the \Program Files\Microchip\ folder. Once the MPLAB X IDE has finished its initialization routines, you should notice the "Kit Window" that acknowledges an active connection to the PIC18F57Q84 Curiosity Nano Evaluation Kit

  4. Navigate to the main toolbar's File > Open Project operation to load the demo project folder (*.X) located at \AzureDemo_AnyCloud\examples\PIC18F57Q84_AnyCloud\firmware\PIC18F57Q84_AnyCloud.X

    If the Configuration load error message in red appears in the Output window, click on the Resolve DFP for configuration: default link

  5. Set the PIC18F57Q84_AnyCloud project as the main (currently focused/active) project by right-clicking on it and selecting Set as Main Project

  6. In the Projects window, open the app_rio2_config.h header file by double-clicking directly on the file name

  7. In the app_rio2_config.h header file, set the necessary parameters corresponding to your IoT device

    • WIFI_SSID (name of your Wi-Fi Access Point)
    • WIFI_PSWD (password for your Wi-Fi Access Point)
    • MY_THING_ID (confirm this matches the Common Name in the client certificate)
    • ID_SCOPE (confirm it is mapped to the correct IoT Central application)
    • MODEL_ID (confirm Device Twin Model Identifier (DTMI) is correct)
  8. Verify the project properties are set correctly before building the project by executing the following steps:

    • right-click on the PIC18F57Q84_AnyCloud project

    • select Properties

    • under Connected Hardware Tool, select PIC18F57Q84 Curiosity Nano-SN

    • select the latest version for CMSIS

    • select the latest version for PIC18F-Q_DFP

    • select the latest XC8 version for Compiler Toolchain

      Note If any changes were made in the project properties window, the Apply button should become enabled. Make sure to hit the Apply button before hitting OK

  9. Right-click on the active project and select Clean. Right-click the project again and select Make and Program Device. This operation will automatically build the project before attempting to program the target device.

  10. After the BUILD SUCCESSFUL message appears in the Output window, the application HEX file will be programmed onto the development Board. Once programming has finished, the board will automatically reset and start running its application code.

  11. Observe the debug messages in the terminal window and verify that telemetry and properties are being updated in the IoT Central application.

  12. To restart the entire connection sequence, peform the following steps in order:

    • Power cycle the AnyCloud™ serial bridge board and then press the RESET (or MCLR) button
      • WFI32-IoT Development Board: RESET

      • PIC32 WFI32E Curiosity Board: MCLR

    • Power cycle the PIC18F57Q84 Curiosity Nano Evaluation Kit (or type CTRL-C in the terminal window)
  13. Access your IoT Central application by signing into the IoT Central Portal, clicking on My Apps in the left-hand side navigation pane, and then clicking on the tile that is labeled with the name of your application.

  14. Confirm that telemetry messages are being received and that all other IoT Central functions are working like before when the Python script was running on the PC. The PIC18F57Q84 Curiosity Nano Evaluation Kit should be interacting with IoT Central just like the main Python script was doing earlier.

  15. Using the left-hand navigation pane, click on Devices under Connect, and then click on your device name

  16. Click here to create an additional "Properties" view that allows you to change any of the Cloud-writable properties of the device in the IoT Central application.

  17. Click on the Properties view. Select "Off" for the property "User LED" and click on the Save icon. Observe that LED0 on the PIC18F57Q84 Curiosity Nano Evaluation Kit is actually off.

  18. Try changing the telemetry interval to see if you can speed up (or slow down) the rate of the telemetry messages being sent from the device. Don't forget to hit the Save icon each time after changing the value.

  19. Click on the Commands view. Type any text message in the "String to send" box and click on the Run button. To see the echo'ed message response from the device, click on the command history link (located just underneath the Run button). You should see that the response was received "now" (i.e. within the last minute) and that the correct message was echoed from the device.

NOTE: You can access any of your IoT Central applications in the future by accessing the IoT Central Portal.

At this point, you have a working embedded firmware project to use as a starting point for a new proof-of-concept and/or IoT device design!