UPC EETAC Bachelor's Degree in Telecommunications Systems and in Network Engineering EEL

 

1-digit BCD counter using FSM control flow and MCC Melody

MCC 


1. Specifications Planning Dev. & test Prototype Report

Let us program a basic application using MCC Melody hardware configuration functions. It will be a professional alternative programming style to access, configure and control all the microcontroller hardware resources. The aim is to examine the differences to the same application programmed in bare metal in CSD available at Counter_BCD_1digit.

- Count enable (CE), terminal count (TC10), 1-digit BCD up counting.

- ST/SP button to start and stop counting.

- TMR0 used as the CLK to generate a 10 Hz counting frequency.

- Pinning adapted to the CSD_PICstick board.

- FSM style to control the program flow.

Symbols

Fig 1. Symbol.

Infer a timing diagram.

 


Specifications 2. Planning Dev. & test Prototype  Report

A) Planning hardware

The basic ideas on planning are explained in shown in Counter_BCD_1digit. We simply will adapt pinning to the CSD_PICstick platform.

We will run MCC to generate all the required functions to control hardware resources as it were another tutorial.  

MCC resources

Fig 2. Hardware resources selected from the Melody code configurator.

 


B) Planning software

As shown in the state diagram, we will introduce a hierarchy of FSM. The top control FSM that will run/stop the counter FSM in the corresponding state. 

State diagram

Fig 3. FSM diagrams. TMR0 will be in use only when counting. In this way it is easy to add new functionalities and reuse peripherals.

The second FSM for counting in BCD is a module that will run only when ordered by the control FSM.

Hardware and software diagram

Fig 4. Hardware-software diagram.

Project location:

C:\DEE\LAB7\PIC18F\Counter_BCD_1digit

 


Specifications Planning 3. Dev. & 4. test Prototype Report

A) Developing hardware

We can use some elements of the CSD_PICstick board modelled in Proteus as the hardware platform where to check our circuit. The TMR0 will run to generate overflow interrupts every TW = 100 ms.

Circuit captured in proteus

Fig 4. Circuit captured in Proteus modelling the CSD_PICstick board resources.

 


B) Developing software

The full project "Counter_BCD_1digit_MCC.zip". Start a project using MPLAB v6.25 or newer and XC8 v3.00 or newer.

Use Proteus 9.0 or newer to simulate the application or download the programming file to the CSD_PICstick using MPLAB SNAP.

 


C) Step-by-step testing

Circuit running

 


Specifications Planning Dev. & Test 5. Prototype Report

 


Specifications Planning Dev. & Test Prototype 6. Report