Saturday, October 26, 2019

My First Curiosity Development Board Project

Objective: 
  • Familiar with Microchip Curiosity Development Board
  • Install and setup MPLAB X IDE
  • Familiar with DAC, CLC, TMR, PWM and C programming, and basic MPLAB IDE operation.
  • Confirm multiple independent function can be executed in PIC16F1619.

Project Initial Setup:
  1. Hardware:
    1. One "Curiosity Development Board", from Amazon, $20.
    2. One mini USB cable
    3. One Oscilloscope
  2. Software:
    1. Install MPLAB X IDE from https://microchipdeveloper.com/mplabx:installation
    2. Resource: https://www.youtube.com/watch?v=7MqyU0Lxj08

Start A New MPLAB Program (draft note only):
  1. Start MPLAB
  2. File--> Stand along project
  3. Enter device name, in my case, it is PIC16F1619
  4. Select "None" for debug header
  5. Select "Curiosity" in select tool window
  6. Select "XCB" in select compiler window.  Install one if missing.
  7. Provide project name, such as "My test code"
  8. Save "MyConfig.mc3" in "Save MCC Configuration File" window.
  9. Choose "PDIP20" in package pull down tab in "Pin Management Grid View".
  10. MPLAB is ready for programming

Project Objective:
  1. Setup "Saw Shape" signal generator with C code and DAC peripheral.
  2. General two clocks, they are 250KHz and 500Hz with TMR and PWM peripheral.  Setup up one switch to select signal with CLC peripheral but without using CPU's resource.
  3. About two signals process are run simultaneously and independently.
System Environment Setup:
Required Peripherals List

Setup Oscillator with "INTOSC..." and "1MHz".  This internal clock setting affect saw signal frequency directly.

Pin module setting -1

Pin module setting -2

Saw Shape Signal Generator:

Add a simple DAC code
Make sure check two check boxes.
DAC1OUT>>RA0, see the lock symbol in green box.


For 250K and 500 Hz Signal Switch: 
CLC1 setting, need assign "CLCIN0" and "CLCIN1" in above chart.
S1 >> RC4 >>CLCIN0 choose signal between CLCIN1 << PWM3 or CLCIN2<<PWM4
PWM3OUT>>CLCIN1, please note the right two corners' link symbol at RC3 (not show).

PWM4OUT>>CLCIN2, , please note the right two corners' link symbol at RC2 (not show).
CLC1OUT>>RC5, see lock symbol in green box.
Signal Flowchart, use RC4 to control switch to provide either 500Hz or 250KHz output to RC5.


Set clock range and precise Timer Period.  The Timer Period (ex, 2ms) define the timer frequency.
Set duty cycle and source of timer.
Set timer
Set duty cycle and source of timer, when Timer2 using "FOSC" as its source, PWM4 does not show any parameter in PWM parameter.  But, Timer2 using "FOSC/4" as its source, PWM parameters will be populated.  See PWM3 for comparison.  This issue seems not significant issue since both work either or not the PWM parameter has been populated in this window or not.  

Testing Microchip:
Ground: blue wire, RA0: white wire DAC output, RC5, blue wire timer/PWM signal output.
Yellow line: 230Hz saw signal has been generated by DAC and C code.  Its signal is not linear and very noise.  It could be a DAC bug from PIC16F1619.

Blue line: 250K Hz clock when S1 is off/not pressed.
Yellow line from generated by DAC which is quite noise.

S1 switch
Frequency has been dropped to 500Hz clock when S1 is pressed.

Programming Code:
#include "mcc_generated_files/mcc.h"
void main(void)
{
    // initialize the device
    SYSTEM_Initialize();
    uint8_t count=0;
    DAC1_Initialize();
    
    while (1)
    {
        for(count=0; count<=255; count++)
        {
            DAC1_SetOutput(count);
            //__delay_ms(1);
        }
    }
}

Summary:
This 20$ Curiosity Development Board is a very a very different but a powerful  board compare to Arduino.  You can set and execute multiple functions on the same chip and run interdependently.  Many functions can be operated without using CPU resource too. 

My favor peripheral are Timer, PWM and CLC.  They can be set easy without code, and run very fast.  My less favor part is DAC because it is very slow and very noise at the same time.  The worst part is poor signal linearity issue.

I am happy having this board, and will use it on my future project.  However, the first time I try it, I almost give up and return it back to Amazon within the same day.  Here is why:

  1. Cannot find much information on book or internet about this board.
  2. MPLAB X IDE is very complicate.
  3. Many operation concept are new compare to Arduino's.
  4. It is for advance user.  Very steep learning curve.  
  5. Cannot follow some examples since it demos with a different board from Microchip website.  Some peripheral's name, and option are different in their demonstration.
  6. User much familiar with C programming coding.
  7. User must familiar with logical gate.
  8. User must has sufficiency tool to work with this board, such as oscilloscope and etc.
  9. Microchip company do not provide example or detail description on many peripheral such as AT, CCP, CRC, CWG, ZDC, MSSP, FVR and etc.
PIC16F1619 is a power chip, it opens a new application opportunity to me such as HDMI signal handling, and different clock signal source.  But NOT recommend for beginner unless you can find help from experienced user. 

This is my first time using this board.  When writing this blog, I only have about two days trial and error experience on this board.  If you see error, please do not hesitate let me know.  Thanks.  

Resource:

No comments:

Post a Comment