Comprehensive technical documentation for developing embedded applications with the MPLAB Blockset.

Documentation Sections

🔧 Development Workflow

Core Concepts

Code Generation Pipeline

The MPLAB Blockset uses MATLAB’s Embedded Coder to generate C code from Simulink models:

  1. Model Configuration - Set target chip, clock frequency, optimization settings
  2. Block Configuration - Configure peripheral blocks (PWM, ADC, UART, etc.)
  3. Code Generation - Simulink generates C code using block TLC templates
  4. Compilation - XC compiler builds executable firmware
  5. Programming - Flash .hex file to microcontroller
  6. Validation - Test with External Mode or PIL

Supported Toolchains

  • XC16 - dsPIC30F, PIC24F compiler
  • XC-DSC - dsPIC33 family compiler (33F, 33E, 33C, 33A)
  • XC32 - PIC32 and SAM ARM Cortex-M compiler
  • MPLAB X IDE - Integrated development environment (optional)

Key Features

Automatic Resource Management

  • Pin Assignment - Automatic PPS (Peripheral Pin Select) configuration
  • Timer Allocation - Named timers prevent conflicts
  • Interrupt Priority - Configurable interrupt levels with validation

Multitasking Scheduler

  • Rate Monotonic - Priority-based preemptive scheduler
  • Multiple Sample Times - Different execution rates for tasks
  • Deadline Monitoring - Detect and report timing violations

Optimization Features

  • Hardware Acceleration - Assembly code replacement for critical functions
  • DMA Support - Direct memory access for high-throughput peripherals
  • Code Size Optimization - Compiler optimization levels and linker settings

Advanced Topics

External Mode Operation

Real-time communication between Simulink and target hardware:

  • Modify parameters without recompiling
  • Monitor signals and scopes in real-time
  • Debug control algorithms interactively

Processor-in-the-Loop (PIL)

Verify generated code on actual hardware:

  • Validate numerical accuracy
  • Measure execution time
  • Profile CPU utilization

Best Practices

  1. Model Organization - Use subsystems to organize complex models
  2. Sample Time Selection - Choose appropriate rates for each task
  3. Code Review - Inspect generated code for optimization opportunities
  4. Testing Strategy - Simulate before hardware, validate with PIL
  5. Version Control - Track model changes and configuration settings

Technical Reference

Additional Resources

  • Microchip Documentation - Datasheets, family reference manuals, application notes
  • MATLAB Documentation - Simulink, Embedded Coder, Fixed-Point Designer
  • Community Support - Microchip forums, MATLAB Answers, GitHub issues

Need specific information?Block Reference | Getting Started

Code Generation

Navigation 🏠 Home User Guide Topics Code Generation External Mode PIL Testing Compiler Setup 📹 Video Demos The MCHP Blockset automatically generates …

Read more →

Compiler Setup

Navigation 🏠 Home User Guide Topics Code Generation External Mode PIL Testing Compiler Setup 📹 Video Demos Detailed instructions for installing and …

Read more →

External Mode

Navigation 🏠 Home User Guide Topics Code Generation External Mode PIL Testing Compiler Setup 📹 Video Demos External Mode enables real-time parameter …

Read more →

PIL Testing

Navigation 🏠 Home User Guide Topics Code Generation External Mode PIL Testing Compiler Setup 📹 Video Demos PIL testing verifies generated code by …

Read more →