Core Timer Code Development How you could have

  • Slides: 29
Download presentation
Core Timer Code Development How you could have done the Take. Home Quiz using

Core Timer Code Development How you could have done the Take. Home Quiz using a test driven development (TDD) approach TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

To be tackled today l Test driven development example l Customer l requirements Possible

To be tackled today l Test driven development example l Customer l requirements Possible system test provided by customer’s FAE (field application engineer) l Development 12/31/2021 of your unit tests TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 2

Customer Requirements l Long term goal is that we will be using devices that

Customer Requirements l Long term goal is that we will be using devices that need to be activated at certain reliable times. Seems like we need a library of timer functions 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 3

Customer Test – example code Put system into known state We already have these

Customer Test – example code Put system into known state We already have these LED utilities (Lab. 2) Here is the sort of thing we need This sort of test detail may indicate that FAE has already tried and failed. Be polite when you deliver code 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 4

Define the functions l To be coded in assembly code l l ulong Set.

Define the functions l To be coded in assembly code l l ulong Set. Core. Timer(initial, reload, scale) l l Starts and stops the timer. When started the timer is to run continuously. ulong Read. Core. Timer(void) l l Initializes the core timer registers, returns old control setting, places timer in low power mode, stops the clock void Start. Core. Timer(void), void Stop. Core. Timer(void) l l Convention when dealing with hardware Returns current value from the timer bool Check. If. Core. Timer. Expired(void) l 12/31/2021 Determines whether or not the core timer registers have been reloaded TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 5

Step 1 A – Get a main( ) and a test to compile and

Step 1 A – Get a main( ) and a test to compile and link – Design the test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 6

Step 1 B – Get a main( ) and a test to compile and

Step 1 B – Get a main( ) and a test to compile and link – Design main l Bring a copy of your Take-Home Quiz code to compare 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 7

Recode till pasts the test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University

Recode till pasts the test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 8

Step 2 A – Write the test for void Stop. Core. Timer(void); 12/31/2021 TDD-Core

Step 2 A – Write the test for void Stop. Core. Timer(void); 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 9

Step 2 B – Write and Test void Stop. Core. Timer. ASM(void); l Bring

Step 2 B – Write and Test void Stop. Core. Timer. ASM(void); l Bring a copy of your Take-Home Quiz code to compare 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 10

Step 2 C – Fix the test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith,

Step 2 C – Fix the test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 11

3 A – Write a test -- unsigned long int Read. Core. Timer( )

3 A – Write a test -- unsigned long int Read. Core. Timer( ) 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 12

3 B – Write the code to pass the test l Bring a copy

3 B – Write the code to pass the test l Bring a copy of your Take-Home Quiz code to compare 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 13

4 Write the Test for void Start. Core. Timer. ASM(void) 12/31/2021 TDD-Core Timer Library,

4 Write the Test for void Start. Core. Timer. ASM(void) 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 14

4 – Write the code to satisfy the test l Bring a copy of

4 – Write the code to satisfy the test l Bring a copy of your Take-Home Quiz code to compare 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 15

Test failed because 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary,

Test failed because 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 16

4 Rewrite the test – prefer new -- unsigned long int Start. Core. Timer(void)

4 Rewrite the test – prefer new -- unsigned long int Start. Core. Timer(void) 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 17

4 -- Need to add unsigned long int Set. Core. Timer(ulong, ulong) 12/31/2021 TDD-Core

4 -- Need to add unsigned long int Set. Core. Timer(ulong, ulong) 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 18

Needed code – run the tests l Bring a copy of your Take-Home Quiz

Needed code – run the tests l Bring a copy of your Take-Home Quiz code to compare 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 19

New tests pass – old tests now fail 12/31/2021 TDD-Core Timer Library, Copyright M.

New tests pass – old tests now fail 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 20

Fix Stop. Core. Timer( ) 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University

Fix Stop. Core. Timer( ) 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 21

Re-examine Read. Core. Timer. ASM 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University

Re-examine Read. Core. Timer. ASM 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 22

4 – Re-examine Test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of

4 – Re-examine Test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 23

Final Test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Final Test 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 24

Customer Test Put system into known state We already have these LED utilities (Lab.

Customer Test Put system into known state We already have these LED utilities (Lab. 2) Here is the sort of thing we need This sort of test detail may indicate that FAE has already tried and failed. Be polite when you deliver code 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 25

Oops -- Still missing code for bool Check. If. Core. Timer. Expired. ASM( )

Oops -- Still missing code for bool Check. If. Core. Timer. Expired. ASM( ) l First 12/31/2021 – write the test TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 26

Oops - Still missing code for bool Check. If. Core. Timer. Expired. ASM( )

Oops - Still missing code for bool Check. If. Core. Timer. Expired. ASM( ) l Now 12/31/2021 write the code TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 27

Tackled today l Test driven development example l Customer requirements l Possible system test

Tackled today l Test driven development example l Customer requirements l Possible system test provided by customer’s FAE (field application engineer) l Development of your unit tests l You still need to design the test and the code for bool Check. If. Core. Timer. Expired. ASM(void); 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 28

l Information taken from Analog Devices On-line Manuals with permission http: //www. analog. com/processors/resources/technical.

l Information taken from Analog Devices On-line Manuals with permission http: //www. analog. com/processors/resources/technical. Library/manuals/ l Information furnished by Analog Devices is believed to be accurate and reliable. However, Analog Devices assumes no responsibility for its use or for any infringement of any patent other rights of any third party which may result from its use. No license is granted by implication or otherwise under any patent or patent right of Analog Devices. Copyright Analog Devices, Inc. All rights reserved. 12/31/2021 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 29