#MicroXplorer Configuration settings - do not modify
File.Version=6
KeepUserPlacement=false
Mcu.Family=STM32L4
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SYS
Mcu.IP3=USART2
Mcu.IPNb=4
Mcu.Name=STM32L476V(C-E-G)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PA0
Mcu.Pin1=PA1
Mcu.Pin2=PA2
Mcu.Pin3=PA3
Mcu.Pin4=PA5
Mcu.Pin5=PB2
Mcu.Pin6=PE8
Mcu.Pin7=PD5
Mcu.Pin8=PD6
Mcu.Pin9=VP_SYS_VS_Systick
Mcu.PinsNb=10
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32L476VGTx
MxCube.Version=5.0.1
MxDb.Version=DB.5.0.1
NVIC.BusFault_IRQn=true:0:0:false:false:true:false
NVIC.DebugMonitor_IRQn=true:0:0:false:false:true:false
NVIC.HardFault_IRQn=true:0:0:false:false:true:false
NVIC.MemoryManagement_IRQn=true:0:0:false:false:true:
false
NVIC.NonMaskableInt_IRQn=true:0:0:false:false:true:false
NVIC.PendSV_IRQn=true:0:0:false:false:true:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true:0:0:false:false:true:false
NVIC.SysTick_IRQn=true:0:0:false:false:true:false
NVIC.UsageFault_IRQn=true:0:0:false:false:true:false
PA0.GPIOParameters=GPIO_PuPd,GPIO_Label
PA0.GPIO_Label=JOY_C
PA0.GPIO_PuPd=GPIO_PULLDOWN
PA0.Locked=true
PA0.Signal=GPIO_Input
PA1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
PA1.GPIO_Label=JOY_L
PA1.GPIO_Mode=GPIO_MODE_INPUT
PA1.GPIO_PuPd=GPIO_PULLDOWN
PA1.Locked=true
PA1.Signal=GPIO_Input
PA2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
PA2.GPIO_Label=JOY_R
PA2.GPIO_Mode=GPIO_MODE_INPUT
PA2.GPIO_PuPd=GPIO_PULLDOWN
PA2.Locked=true
PA2.Signal=GPIO_Input
PA3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
PA3.GPIO_Label=JOY_U
PA3.GPIO_Mode=GPIO_MODE_INPUT
PA3.GPIO_PuPd=GPIO_PULLDOWN
PA3.Locked=true
PA3.Signal=GPIO_Input
PA5.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
PA5.GPIO_Label=JOY_D
PA5.GPIO_Mode=GPIO_MODE_INPUT
PA5.GPIO_PuPd=GPIO_PULLDOWN
PA5.Locked=true
PA5.Signal=GPIO_Input
PB2.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_
Label,GPIO_ModeDefaultOutputPP
PB2.GPIO_Label=LD_R
PB2.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
PB2.GPIO_PuPd=GPIO_PULLDOWN
PB2.GPIO_Speed=GPIO_SPEED_FREQ_LOW
PB2.Locked=true
PB2.PinState=GPIO_PIN_RESET
PB2.Signal=GPIO_Output
PCC.Checker=true
PCC.Line=STM32L4x6
PCC.MCU=STM32L476V(C-E-G)Tx
PCC.PartNumber=STM32L476VGTx
PCC.Seq0=0
PCC.Series=STM32L4
PCC.Temperature=25
PCC.Vdd=null
PD5.GPIOParameters=GPIO_PuPd
PD5.GPIO_PuPd=GPIO_PULLUP
PD5.Locked=true
PD5.Mode=Asynchronous
PD5.Signal=USART2_TX
PD6.Locked=true
PD6.Mode=Asynchronous
PD6.Signal=USART2_RX
PE8.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_
Label,GPIO_ModeDefaultOutputPP
PE8.GPIO_Label=LD_G
PE8.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
PE8.GPIO_PuPd=GPIO_PULLDOWN
PE8.GPIO_Speed=GPIO_SPEED_FREQ_LOW
PE8.Locked=true
PE8.PinState=GPIO_PIN_RESET
PE8.Signal=GPIO_Output
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=true
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32L476VGTx
ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.13.0
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=LAB_03.ioc
ProjectManager.ProjectName=LAB_03
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-
HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-
MX_USART2_UART_Init-USART2-false-HAL-true
RCC.FamilyName=M
RCC.HSE_VALUE=8000000
RCC.HSI_VALUE=16000000
RCC.IPParameters=FamilyName,HSE_VALUE,HSI_VALUE,LS
COPinFreq_Value,LSE_VALUE,LSI_VALUE,MSI_VALUE,PL
LPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_V
alue,PLLSAI1PoutputFreq_Value,PLLSAI1QoutputFreq_Value,
PLLSAI1RoutputFreq_Value,PLLSAI2PoutputFreq_Value,PLLS
AI2RoutputFreq_Value,SAI1Freq_Value,SAI2Freq_Value,VCOI
nputFreq_Value,VCOOutputFreq_Value,VCOSAI1OutputFreq_
Value,VCOSAI2OutputFreq_Value
RCC.LSCOPinFreq_Value=32000
RCC.LSE_VALUE=32768
RCC.LSI_VALUE=32000
RCC.MSI_VALUE=4000000
RCC.PLLPoutputFreq_Value=4571428.571428572
RCC.PLLQoutputFreq_Value=16000000
RCC.PLLRCLKFreq_Value=16000000
RCC.PLLSAI1PoutputFreq_Value=4571428.571428572
RCC.PLLSAI1QoutputFreq_Value=16000000
RCC.PLLSAI1RoutputFreq_Value=16000000
RCC.PLLSAI2PoutputFreq_Value=4571428.571428572
RCC.PLLSAI2RoutputFreq_Value=16000000
RCC.SAI1Freq_Value=4571428.571428572
RCC.SAI2Freq_Value=4571428.571428572
RCC.VCOInputFreq_Value=4000000
RCC.VCOOutputFreq_Value=32000000
RCC.VCOSAI1OutputFreq_Value=32000000
RCC.VCOSAI2OutputFreq_Value=32000000
USART2.BaudRate=9600
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
USART2.VirtualMode-Asynchronous=VM_ASYNC
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=custom
// Code snippet 1
/* USER CODE BEGIN Includes */
#include <stdbool.h>
/* USER CODE END Includes */
// Code snippet 2
/* USER CODE BEGIN PFP */
/* Private function prototypes ---------------------------------------
--------*/
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small
printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
extern uint32_t read_a_bit_of_a_port(__IO uint32_t *pIDR,
uint32_t pinMask);
extern void set_a_bit_of_a_port(__IO uint32_t *pODR, uint32_t
pinMask);
extern void clear_a_bit_of_a_port(__IO uint32_t *pODR,
uint32_t pinMask);
#define LD_R_ON // Add the appropriate function here
#define LD_G_ON // Add the appropriate function here
#define LD_R_OFF // Add the appropriate function here
#define LD_G_OFF // Add the appropriate function here
#define JOY_C_IS_PRESSED // Add the appropriate function
here
#define JOY_L_IS_PRESSED // Add the appropriate function
here
#define JOY_R_IS_PRESSED // Add the appropriate function
here
/* USER CODE END PFP */
// Code snippet 3
enum progState{State1 = 1, State2, State3, State4};
enum progState currentState = State1;
bool stateChanged = true;
bool ledON = true;
uint32_t bDelay = 100;
// Code snippet 4
if (stateChanged)
printf("The current state is State%1d.nr", currentState);
switch (currentState) {
case State1:
if (stateChanged) {
printf("Press the center key to go to State 2.nr");
stateChanged = false;
}
if (JOY_C_IS_PRESSED) {
currentState = State2;
stateChanged = true;
break;
}
if (ledON) {
LD_R_ON;
LD_G_OFF;
} else {
LD_R_OFF;
LD_G_ON;
}
HAL_Delay(bDelay);
ledON = !ledON;
break;
case State2:
if (stateChanged) {
// provide your hint to the user and set your "state
changed" flag
}
if (JOY_C_IS_PRESSED) {
// provide your code to handle the center Joy key input.
}
if (JOY_L_IS_PRESSED) {
// provide your code to handle the left Joy key input.
}
if (JOY_R_IS_PRESSED) {
// provide your code to handle the right Joy key input.
}
LD_R_OFF;
LD_G_OFF;
break;
case State3:
if (stateChanged) {
// your code
}
// your state transition code
if (ledON) {
LD_R_ON;
} else {
LD_R_OFF;
}
LD_G_OFF;
HAL_Delay(2*bDelay);
ledON = !ledON;
break;
case State4:
if (stateChanged) {
// your code
}
// your state transition code
// your LED code
break;
default:
printf("The program should not print this line---something
is deadly wrongnr");
break;
}
Course #: CEC 322
Program Outcome: EAC-B. Ability to design and conduct
experiments, as well as to analyze and
interpret data.
Artifact: Lab 5. State Machine, Macro, and Assembly
Attribute
Student Performance
Unsatisfactory (1) Satisfactory (2) Excellent (3)
a. Improving
readability of the
program code
using macros.
Cannot define macros
using Joystick key
reading functions or LED
control functions without
being guided almost step
by step.
Can define macros using
assembly Joystick key
reading functions and
LED control functions
to produce correct
results with some help.
Can define macros using
assembly Joystick key
reading functions and
LED control functions to
produce correct results
without any help.
b. Logic flow of
mixed C and
assembly
programming.
Major code
snippets should be
included in the lab
report, including
those for the
attributes given
below.
Disorganized programs,
the results are
unpredictable; programs
are unable to accomplish
expected assignments;
syntax flaw; student can't
describe what the
program will do. Student
was unable to complete
lab without being guided
almost step by step.
Program is organized in
terms of functionalities
with required results
achieved; variables,
loops, subroutines and
conditions are not
redundant; students can
explain most of work.
Program is logically
organized and work well
according to requirements;
variables, loops,
subroutines and conditions
are effective designed,
student can explain to the
code in the program.
c. Reading from
GPIO pins
connected to
selected Joystick
keys using
assembly
functions. These
keys should be
checked for their
status without
being affected by
other GPIO pins.
Fail in any one of the
following: (1) reading
the Joystick input keys,
(2) isolating the input of
one Joystick key from
other Joystick keys.
Perform all the
following in assembly
without error: (1)
reading the input keys,
(2) isolating the input of
one key from other
GPIO pins. May not be
very efficient.
Perform all the following
efficiently in assembly
without any error: (1)
reading the input keys, (2)
isolating the input of one
key from other GPIO pins.
Code is written cleanly.
d. Writing to GPIO
pins to drive LEDs
using assembly
functions. Other
pins in the port
cannot be affected.
Fail in any one of the
following: (1) writing the
pins to turn on/off LEDs
and (2) keeping other
GPIO pins on the same
port unchanged.
Perform of the following
in assembly without any
error: (1) writing the
pins to turn on/off LEDs
and (2) keeping other
GPIO pins on the same
ports unchanged. May
not be very efficient.
Perform of the following
efficiently in assembly
without any error: (1)
writing the pins to turn
on/off LEDs and (2)
keeping other GPIO pins
on the same ports
unchanged. Code is
written cleanly.

#MicroXplorer Configuration settings - do not modifyFile.Versio.docx