wiki:examples:pic_tutorial
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wiki:examples:pic_tutorial [2019/05/01 19:15] – pmueller | wiki:examples:pic_tutorial [2022/08/17 17:43] (current) – Discussion status changed pmueller | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Getting started with the PIC16F18446 and State Machines ====== | ====== Getting started with the PIC16F18446 and State Machines ====== | ||
- | This tutorial explains | + | This tutorial explains |
+ | |||
+ | {{ : | ||
+ | (Source: Microchip) | ||
Install the required software if you want to follow all steps yourself. Otherwise just go on reading. | Install the required software if you want to follow all steps yourself. Otherwise just go on reading. | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
- | * [[wiki: | + | * [[wiki: |
* [[https:// | * [[https:// | ||
For this tutorial we will use just the push botton and the LED on the board. So you can follow it without any additional hardware required. The LED shall blink all the time. The frequency can be changed from slow to fast by pressing the button. Simple enough but sufficient to show all the key concepts we are going to use. | For this tutorial we will use just the push botton and the LED on the board. So you can follow it without any additional hardware required. The LED shall blink all the time. The frequency can be changed from slow to fast by pressing the button. Simple enough but sufficient to show all the key concepts we are going to use. | ||
- | The PINs are allocated | + | The PINs are allocated using the MPLAP X IDE Resource Manager as well as the 4MHz system clock and the 10ms Timer0. I've not used this configurator before. But have to say that it is a very convinient way to setup the hardware. I would wish to have the same for the MSP430 μCs I also often use. |
- | ===== Step 1 - Deciding the system | + | ===== Step 1 - Deciding the system |
For small systems e.g. sensor nodes it is usually sufficient use a main loop design. The main loop cycles endlessly and waits for events. Events are benefitially stored in an event queue. The queue is filled from timer events, other state machines (cooperating machines) or interrupt handlers. If events are available the state machine(s) are called from the main loop to process them. | For small systems e.g. sensor nodes it is usually sufficient use a main loop design. The main loop cycles endlessly and waits for events. Events are benefitially stored in an event queue. The queue is filled from timer events, other state machines (cooperating machines) or interrupt handlers. If events are available the state machine(s) are called from the main loop to process them. | ||
- | In our little example events are sent from the keyboad interrupt and from a software timer module which is called regulary from the cyclic hardware timer. The following figure shows the system | + | In our little example events are sent from the keyboad interrupt and from a software timer module which is called regulary from the cyclic hardware timer. The following figure shows the system |
{{ : | {{ : | ||
Line 72: | Line 75: | ||
===== Step 3 - Integrating the state machine in MPLAB X ===== | ===== Step 3 - Integrating the state machine in MPLAB X ===== | ||
- | The generated state machine code files can be easily added to the PIC project. It is recommended to create a new folder e.g. called '' | + | The generated state machine code files can be easily added to the PIC project. It is recommended to create a new folder e.g. called '' |
The following figure shows the project tree with all generated files. | The following figure shows the project tree with all generated files. | ||
Line 111: | Line 114: | ||
Peter | Peter | ||
- | {(rater> | + | |
- | ~~DISCUSSION|Leave your comments~~ | + | ~~DISCUSSION:closed|Leave your comments~~ |
{{tag> | {{tag> | ||
+ | |||
wiki/examples/pic_tutorial.txt · Last modified: 2022/08/17 17:43 by pmueller