upc eetac_1

Week 9

Week 10: Basic I/O, interrupts and FSM structure

Week 11



[28/11]

Guided activities #10

[P10] Interrupts and push-button edge detection

 


Detecting signal transitions (rising and falling edges) by means of interrupts to the main program. Interrupt hardware flags from peripheral sybsystems (timers, A/D, USART, etc). The interrupt mechanism. Software variables associated to interrupt flags in the ISR() function.

For instance: Modify the 1-digit BCD adder example so that the truth table is calculated only when a EXEC pushbutton is pressed. Hardware flag: INT0F, software variable: EXEC_flag.

- The idea of tri-state gates and bidirectional wires and buses. How to set the direccion (TRISn) of a pin as input or as output?

 


[02/12]

Laboratory #10

[P10] FSM design programming in C.

- State enumeration (Plan X)

- Large counters (Plan Y)

 

 

Let's learn how to implement a FSM using C language: the Counter_BCD_1digit project as a FSM tutorial. 

In the general diagram, you see that the main program runs continuously, updating current_state in each loop of the main program. If you have larger C code, it takes longer to refresh the state variable. If you change the crystal quartz oscillator frequency, it will also take a different time to refresh the state variable.

Therefore, how to synchronise operations like changing states in a FSM by means of an external CLK signal as it was done in Chapter 2? Using an external CLK signal or an internal one from a peripheral such a timer (in P12).

 


Learn how to implement as a FSM a Counter_mod256  or any other large counter such as a Counter_mod6578 project

If there are too many states, the FSM cannot be enumerared, thus, let's organise the architecture as in the Chapter 2 Plan Y, which consisted in using the current_state as a vector variable. This time a variable type char, int, etc. (depending on the number of bits required).  A char variable can hold up to 256 states.

 


[03/12]

Lecture #10

[P10] FSM design programming in C.

- Example of a dedicated processor (FSM and datapath) architecture in C

 

Questionnaire #Q2.2 on P7 -P8.

Examine the problem of the 3-bit Gray counter

Examine a counter type 74HC4017. 

Another example: The project proposed in P10: build a 6-bit Johnson counter (Counter_Johnson_6bit).

Examine the P10 project: 6-bit Johnson counter with start/stop button.

 


Let's study the example of the Timer_MMSS, which is a large system. For instance solved in P8 as a dedicated processor based on a datapath and a control unit (FSM). How to design it using C ?

As a complement this class you are invited to read books on basic theory on microcontrollers: library. Find answers to questions.