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

Chapter 3 problems

- D3.22 -

Bit pattern generator (µC - C)

Products

D3.21

D3.23


1. Specifications

Design a 12-bit pattern generator using a PIC18F46K22.

The same project designed using hardware is shown in D2.22.

Symbols and features

Fig. 1. Symbols and features.

Some example patterns are represented in Fig. 2.

Wave 1

Fig. 2. Bit pattern examples.

Discuss the given specifications. Which inputs are required to be external interrupt sources?

 

2. Planning

The product will be developed by organising several design phases, with multiple steps within each phase.

Design phase #1: basic features

Solve the circuit for this design step #1. Only when it is fully tested, working correctly and reported, solve design step #2.

Design step #1. Start/stop a 12-bit example pattern stream, for instance, "100111101010". When the user clicks PB_L, the sequence is generated continuously at the TCLK bit rate. Clicking the same button again stops the pattern generation.

Project location:

 C:\CSD\P10\P_gen_12bit_s1\(files)

Project source files:

"P_gen_12bit.pdsprj", "P_gen_12bit.c"

A) Planning hardware

Copy and adapt a circuit from a convenient tutorial project and name it "P_gen_12bit.pdsprj".

a) Draw the hardware schematic necessary for step #1, as shown in Fig. 3. Assign pins to inputs and outputs. Explain how to configure the inputs and outputs in init_system().

Hardware for step 1

Fig. 3. Step #1 hardware to be captured in Proteus. 

B) Planning software

b) Draw the state diagram indicating how the state transitions will work. What outputs are in each state?

- What variables are required?

State diagram step 1

Fig. 4. Idea of state diagram controlled by interrupt flag variables.

c) Draw the hardware/software diagram indicating the required RAM variables and how the FSM is solved in software.

- What variables are required?

- At this initial step, what signals will be read, if any, and when? Organise  read_inputs().

- Organise write_outputs().

- The interrupt sources: do they have to be enabled all the time?

d) Draw the truth tables and their equivalent flowcharts for state_logic() and output_logic() functions.

e) What is the interrupt service routine ISR() used in this application? Draw its flowchart.

f) Develop and test (debug) the project by capturing the hardware circuit in Proteus and writing the C source code (as indicated: always copying and adapting from digsys examples) .

 


Design step #2.  CLK rates, single pattern or continuous mode. The pattern to generate and transmit and the transmission configuration bits are input in two steps using 8 switches attached to port RC(7..0)

Inherit the step #1 source hardware and software files into the new location.

Project location:

 C:\CSD\P10\P_gen_12bit_s2\(files)

Project source files:

"P_gen_12bit.pdsprj", "P_gen_12bit.c"

A) Planning hardware

a) Draw the hardware schematic necessary for step #2. Add the new switches and the green LED. Explain how to configure it in init_system().

 

B) Planning software

Organise and explain what is new in sections b), c), d), e), f)

Develop and test the new features.

 


Design step #3. Implement the S function: 12-bit raw generation or standard byte serial as shown in Fig.1.

Inherit the step #2 source hardware and software files into the new location.

Project location:

 C:\CSD\P10\P_gen_12bit_s3\(files)

Project source files:

"P_gen_12bit.pdsprj", "P_gen_12bit.c"

A) Planning hardware

To implement this last step, we use the same hardware.

 

B) Planning software

Organise and explain what is new in sections b), c), d), e), f)

Develop and test the new features.

 



Design phase #2: LCD display

Let us add an LCD display, as studied in P11, to this application. Print the 12bit pattern generated as a text string, the transmission speed and the configuration parameters.

Project location:

 C:\CSD\P11\P_gen_12bit\(files)

Project source files:

"P_gen_12bit_LCD.pdsprj", "P_gen_12bit_LCD.c"

g) Enhance the schematic from the previous design phase #1 to include an LCD attached to port D as studied in tutorials.

h) Enhance the software and the source file to drive the LCD.

Develop and test the new feature.




Design phase #3: Using the TMR2 peripheral subsystem.

Design step #1.

The external sampling CLK is replaced by the internal 8-bit TMR2 peripheral to generate interrupts (TMR2IF). Discuss the main features of this peripheral and its applications.

Project location:

 C:\CSD\P12\P_gen_12bit\(files)

Project source files:

"P_gen_12bit_LCD_TMR2.pdsprj", "P_gen_12bit_LCD_TMR2.c"

 

i) Calculate TMR2 parameters required to generate a CLK of 8 Hz (var_CLK_flag period = 125 ms) to acquire the pattern and run the machine, replacing the external CLK signal.

Develop and test the new feature.


Optional design step #2.

j) Add the TMR0 to generate a new switch-off (sleep mode) signal after 1 min of inactivity.

Project location:

C:\CSD\P12\P_gen_12bit_LCD_TMR2_sleep\(files)

Project source files:

"P_gen_12bit_LCD_TMR2_sleep.pdsprj", "P_gen_12bit_LCD_TMR2_sleep.c"

Develop and test the new feature.


Optional design step #3.