CSE121 & CSE121L 编程代写、代写c++程序语言

University of California Santa Cruz Baskin School of Engineering CSE121 & CSE121L Spring 2022 Lab 1 Copyright ? 2022 David C. Harrison. All rights reserved.

CSE121 & CSE121L Spring 2022

Lab 1

In this lab you will gain basic familiarity with the PSoC 6 BLE Prototyping Kit (which we’ll just call ‘PSoC 6’ from
now on) and the PSoC Creator IDE you will be using for subsequent labs.

Specifically, you will write programs to blink the PSoC 6’s internal LEDs in four different ways. All programs are
examples of setting the values (voltages) of digital pins on the PSoC 6.

This assignment is worth 5% of your final grade.


Setup

1. Connect your PSoC 6 to a USB port on a lab workstation using the USB 2.0 A male to female cable from your
components kit and the short USB A female to micro male cable from the PSoC 6 package.

2. Update the firmware on your PSoC 6 by starting PSoC Programmer, selecting the Utilities tab and clicking
Upgrade Firmware. Then disconnect then re-connect your PSoC 6.

3. Start PSoC Creator and create a workspace.
File New Project…
Select Workspace then Next
Set Workspace name to CSE121 and click Finish

4. Set the PDL V3 path to C:\Program Files (x86)\Cypress\PDL\3.1.5 ( or 3.1.3 )
Tools Options Project management

5. Create an empty project that can be used to re-set you PSoC 6 to a known state.
File New Project…
Set Target device to PSoc 6 and Launch Device Selector
In Device Selector, scroll down and select CYBLE-416045-02 then click OK
Click Next
Select Empty schematic and click Next
Click Next again
Set Project name to Lab1.0 and click Finish
Build Generate Application
Debug Select target and program
Select PSoC 6 CYBLE-416045-02 (CM4) and OK / Connect
Watch for output in the window at the bottom of PSoC Creator
When you see Device ‘PSoC 6 CYBLE-416045-02 (CM4)’ was successfully programmed you have
successfully created the empty project and programmed your PSoC 6.

Background information

Pulse Width Modulation

A Pulse-Width Modulator (PWM) is a component used by digital systems to generate control signals for hardware.
Its periodic rectangular (modified square) signal can be used for many applications including driving a speaker,
rotating a servo motor, or making an LED blink at a regular interval.

By adjusting the duty cycle (portion of the period that the power is on), a PWM can be used to control the average
power supplied, which can be used for a variety of functions including dimming an LED as we’ll see in Lab 2.

For more details see: https://en.wikipedia.org/wiki/Pulse-width_modulation
University of California Santa Cruz Baskin School of Engineering CSE121 & CSE121L Spring 2022 Lab 1 Copyright ? 2022 David C. Harrison. All rights reserved.

Requirements

Lab 1.1 Hardware Only

Whilst the PSoC 6 has two CPUs, it is possible to have on-board hardware set the values of digital pins without
the involvement of either CPU. Here you will drive the on-board PWM with an on-board clock to switch the voltage
of the digital pins the two internal LEDs are connected to from high to low (zero volts) every half second.

Lab 1.2: Single CPU

Have the PSoC 6’s CM0+ CPU switch the voltage of the digital pins the two internal LEDs are connected to by
making use of the PSoC 6 Peripheral Driver Library, details of which can be found on-line on the manufacture’s
web site: https://infineon.github.io/psoc6pdl/pdl_api_reference_manual/html/index.html

Lab 1.3: Multiple CPUs

By using the PSoC 6 Peripheral Driver Library, have the PSoC 6’s CM0+ CPU switch the voltage of the digital pin
one the two internal LEDs is connected to and have the PSoC 6’s CM4 CPU switch the voltage of the digital pin
the other internal LED is connected to.

Lab 1.4: FreeRTOS

The code from Lab1.2 and Lab1.3, whilst easy to understand, is inefficient and difficult to scale as we must maintain
the main program loop ourselves. For more realistic embedded systems it is convenient to use a “Real Time
Operating System” (RTOS) to schedule period tasks. Here we deploy FreeRTOS (https://www.freertos.org) on the
PSoC 6’s CM4 CPU and write tasks to independently switch the voltage of the digital pins the two internal LEDs
are connected to using the PSoC 6 Peripheral Driver Library.


What steps should you take to tackle this?

Lab 1.1 Hardware Only

1. Create a new project in the CSE121 workspace:
File New Project…
Set Target device to PSoc 6 and Last used: CYBLE-416045-02
Click Next
Select Empty schematic and click Next
Click Next again
Set Project name to Lab1.1 and click Finish

2. Add two digital pins:
Open TopDesign.cysh
Add a digital pin from Ports and Pins and change its Name to RED
Add a second digital pin and change its Name to GREEN

3. Add a PWM:
Add a PWM from Digital ? Functions and change its Name to PWM
Set the PWM Period 0 to 999
Set the PWM Compare 0 to 500

4. Add a clock:
Add a Clock from System and change its Name to Clock
Set the clock Frequency to 1KHz

5. Connect the components:
Use the Wire Tool to connect the clock to the clock port on the PWM
Use the Wire Tool to connect the PWM pwm port to the RED digital pin
Use the Wire Tool to connect the PWM pwm_n port to the GREEN digital pin
University of California Santa Cruz Baskin School of Engineering CSE121 & CSE121L Spring 2022 Lab 1 Copyright ? 2022 David C. Harrison. All rights reserved.

6. Confirm your TopDesign.cysh looks like this:

7. Set the digital pin port numbers in “Design Wide Resources”:
Set GREEN to port P7[1]
Set RED to port P6[3]

8. Generate software / firmware components.
Build Generate Application

9. Disable CM4, enable the PWM and put CM0+ to sleep:
Edit CM0p Source Files main_cm0p.c
Remove the call to Cy_SysEnableCM4()
Remove the infinite loop for (;;) { }
Start the PWM by adding a call to PWM_Start()
Put CM0+ to sleep by adding a call to Cy_SysPm_Sleep(CY_SYSPM_STATUS_CM0_SLEEP)
Save main_cm0p.c

10. Program the PSoC 6:
Debug Select target and program
Select PSoC 6 CYBLE-416045-02 (CM4) and click OK / Connect
Watch for Device ‘PSoC 6 CYBLE-416045-02 (CM4)’ was successfully programmed’

If all goes well, the red and green on-board LEDs will start blinking on a half second cycle, red on, green off,
green on red off, etc.

Lab 1.2: Single CPU

1. Create a new project in the CSE121 workspace:
As above, but name it Lab1.2

2. Add two digital pins:
As above, but uncheck their General ? Digital output ? HW connection properties

3. Set the digital pin port numbers in "Design Wide Resources":
Set GREEN to port P7[1]
Set RED to port P6[3]

4. Generate software / firmware components
Build Generate Project

5. Disable CM4
Edit CM0p Source Files main_cm0p.c
Remove the call to Cy_SysEnableCM4()

University of California Santa Cruz Baskin School of Engineering CSE121 & CSE121L Spring 2022 Lab 1 Copyright ? 2022 David C. Harrison. All rights reserved.

6. Modify the main control loop to set the RED LED on and off on a half second delay:
Cy_GPIO_Write(RED_PORT, RED_NUM, x); // x = 1 for on, 0 for off
CyDelay(500); // sleep for 500ms

7. Modify the main control loop to do the opposite for GREEN LED on:

8. Program the PSoC 6:
Debug Select target and program
Select PSoC 6 CYBLE-416045-02 (CM4) and OK / Connect
Watch for Device ‘PSoC 6 CYBLE-416045-02 (CM4)’ was successfully programmed’

Lab 1.3: Multiple CPUs

1. As Lab1.2, but with the following differences:
Project name is Lab1.3
Do not disable CM4
Only toggle the RED LED in the CM0+ control loop
Toggle the GREEN LED in the CM4 main control loop

Lab 1.4: FreeRTOS

1. As steps 1 to 3 in Lab1.2, but with the following differences:
Project name is Lab1.4

2. Include support for FreeRTOS:
Use the (right mouse) context menu on the Lab1.4 project:
Build Settings Peripheral Driver Library
Select RTOS FreeRTOS Memory Management ( variant heap_1 )

3. Generate software / firmware components
Build Generate Application

4. Include FreeRTOS header files:
Edit CM4 Source Files main_cm4.c
Hash include FreeRTOS.h and task.h

5. Write a FreeRTOS task start function to toggle the RED LED:
Signature must be void red_task(void *arg)
Use Cy_GPIO_Write to set the pin status as before
Use vTaskDelay instead of CyDelay

6. Intialise a FreeRTOS task to call the start function:
xTaskCreate(red_task, "RED_TASK", 400, NULL, 1, 0);
Study the documentation to understand what the arguments to xTaskCreate signify

7. Repeat steps 5 and 6 for the GREEN LED

8. Start the FreeRTOS task scheduler
Remove the generated infinite loop
Replace with a call to vTaskStartScheduler();

9. Program the PSoC 6:
Debug Select target and program
Select PSoC 6 CYBLE-416045-02 (CM4) and OK / Connect
Watch for Device ‘PSoC 6 CYBLE-416045-02 (CM4)’ was successfully programmed’

University of California Santa Cruz Baskin School of Engineering CSE121 & CSE121L Spring 2022 Lab 1 Copyright ? 2022 David C. Harrison. All rights reserved.

How much code will you need to write?

Almost none. Your FreeRTOS implementation can be factored to avoid duplication, but make sure you have a
simple if inefficient version working before moving on to anything more sophisticated.

Grading scheme

The following aspects will be assessed:

1. (100%) Does it work?

Lab 1.1 Hardware Only (25%)
Lab 1.2 Single CPU (25%)
Lab 1.3 Multiple CPUs (25%)
Lab 1.4 FreeRTOS (25%)

How will you get your work graded?

Submit as described below, then in a TA office hours session, or lab section, demonstrate all four programs to a
TA. They will only award you a grade if you have submitted your code.

What to submit

In PSoC Creator, select:

Build Clean All Projects

Then open PowerShell:

$ cd '.\Documents\PSoC Creator\CSE121'
$ Compress-Archive -Path Lab1.* -DestinationPath CSE121-Lab1.zip

This creates an archive named CSE121-Lab1.zip in the current directory.

热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图