Microchip Toolstrip

The MPLAB Blockset adds a dedicated Microchip tab to the Simulink toolstrip (ribbon). Every common action โ€” configuring the target, inserting a โ€ฆ

Read more โ†’

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 The MPLAB Device Blocks for Simulink โ€ฆ

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 Processor-in-the-Loop (PIL) testing โ€ฆ

Read more โ†’

Tunable Parameters

The Tunable Parameters toolkit lets you expose selected block parameters as calibratable variables โ€” values you can change live on the running target โ€ฆ

Read more โ†’

Dual-Core (dsPIC33CH)

The dsPIC33CH family integrates two CPU cores on one device โ€” a Main core and a Secondary core โ€” that run independently and exchange data through the โ€ฆ

Read more โ†’

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