Design, develop and debug a program in C CODE which uses one of the built in timer/counters and associated interrupts to
Posted: Thu Jul 14, 2022 2:06 pm
Design, develop and debug a program in C CODE which uses one ofthe built in timer/counters and associated interrupts to produce anelapsed time clock capable of displaying seconds and tenths of asecond elapsed time. (Do NOT attempt to use the SysTick for this).Ultimately your design is going to be used in a reflex tester soyou do not need to count beyond 59.9 seconds. If the count isincremented when it is 59.9 seconds it will roll over to 000. Thetimer will be started by a normally open momentary USER BUTTONconnected to pin PA15. Once the key is depressed the timer willbegin. It will use an interrupt to determine when one tenth of asecond has elapsed. The interrupt service routine will update aglobal variable holding the count. The count will be stopped whenthe switch is depressed a second time. The count will be kept inASCII format so it can be displayed. The decimal will be understoodso the count will consist of 3 ascii characters. You do not need todetect any further presses after the second time - simply send yourprogram into a spin lock. Your design goal is to be within 1 μsecof a tenth of a second on each cycle. You should pick a singleappropriate instruction in your code to measure accuracy. Place abreak point on that instruction and measure the tenth second cyclesbeginning on that instruction and ending on that instruction. Use aremark to indicate which instruction you are using for yourmeasurement. The count will be maintained in ascii format as anarray of 3 characters. The decimal does not have to be part of thecount - it will be inserted later when the value is displayed. Theitoa( ) function often used to convert integers to strings is NOTpart of ANSI-C. To maximize portability we will NOT use thisfunction. We will maintain the count as a sequence of ascii codescorresponding to the numbers. The count will begin at "000" or inhex 0x30 0x30 0x30. Counter update consists of incrementing theleast significant digit. If the digit is already 0x39 or '9' , itis set to 0x30 or '0' and the middle digit is incremented. If themiddle digit is to be incremented and it is 0x39 or '9', it is setto 0x30 or '0' and the most significant digit is incremented. Ifthe count is at "599" and is incremented it rolls over to "000".You may want to add __asm("nop"); to the body of any empty loops tomake debugging easier. IMPORTANT: It should program on MicrochipATSAMD21J18 Chip. PLEASE HELP!