Question
Your supervisor has assigned you to build a finite state machine (FSM) in C code to control the operation of a gas pump. You determine
Your supervisor has assigned you to build a finite state machine (FSM) in C code to control the operation of a gas pump. You determine that the required states are:
idle,
-payment card verifying,
-payment approved,
-payment denied,
-nozzle removed,
-waiting for grade selection,
-pumping,
-finalizing transaction (i.e. the nozzle has been returned)
-emergency (someone drove off before removing the nozzle, fire detected, etc
The first thing you decide to do is to custom C data type to represent the states. Using the typedef keyword, custom data type in the answer space. Path:
2)You'll want to refer to Chapters 13 & 14 in the PIC16 User Guide for this question. To make your life easy, pay special attention to Figure 14-3 and Table 14-5. Your supervisor now wants you to set up your PIC16 to perform PWM. You need to initialize TMR2 and CCP1 to make this happen. Your oscillator frequency (fosc) is 20 MHz. The required PWM frequency is 78.125 kHz. You do not need to concern yourself with setting the duty cycle, as another engineer is writing the code for that piece (whew!) Also, notice that the TMR2 postscaler is not utilized in PWM operation, so just leave it at 1:1. Using C hexadecimal format, e.g. 0xE2, provide the initial values for the following control registers:
T2CON =
PR2 =
CCP1CON=
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started