arm m4 peripherals - milwaukee school of engineering
TRANSCRIPT
![Page 1: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/1.jpg)
ARM M4 Peripherals
Last updated 7/8/19
![Page 2: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/2.jpg)
2 © tjEE 2920
ARM M4 Peripherals
![Page 3: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/3.jpg)
3 © tjEE 2920
ARM M4 Peripherals
• Core Peripherals
• SysTick
• System Control Block
• Memory Protection Unit
• Floating Point Unit
• Debug Peripherals
• Nested Vector Interrupt Controller(in interrupts notes)
![Page 4: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/4.jpg)
4 © tjEE 2920
ARM M4 Peripherals
• Systick
• Integrated system timer (counter)
• 24-bit - clear-on-write (reloads)
• Decrementing
• Wrap-on-zero
Reload ValueMax value - 16,777,215
cou
nt wrap
Write(clear)
time
![Page 5: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/5.jpg)
5 © tjEE 2920
ARM M4 Peripherals
• Systick• Applications
• An RTOS tick timer that fires at a programmable rate (for example, 100 Hz) and invokes a SysTick routine.
• A high-speed alarm timer using the system clock.
• A variable rate alarm or signal timer—the duration is range-dependent on the reference clock used and the dynamic range of the counter.
• A simple counter used to measure time to completion and time used.
• An internal clock source control based on missing/meeting durations.
• The COUNT bit in the STCSR control and status register can be used to determine if an action completed within a set duration, as part of a dynamic clock management control loop
![Page 6: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/6.jpg)
6 © tjEE 2920
ARM M4 Peripherals
• Systick
SysTick -> CTRLLOADVALCALIB
1. Program the value in the STRVR register.2. Clear the STCVR register by writing to it with any value.3. Configure the STCSR register for the required operation.
![Page 7: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/7.jpg)
7 © tjEE 2920
ARM M4 Peripherals
• Systick – Control Register SysTick -> CTRL
![Page 8: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/8.jpg)
8 © tjEE 2920
ARM M4 Peripherals
• Systick – Reload Value Register SysTick -> LOAD
![Page 9: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/9.jpg)
9 © tjEE 2920
ARM M4 Peripherals
• Systick – Current Value Register
Note: Writing anything to this register clears the count
SysTick -> VAL
![Page 10: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/10.jpg)
10 © tjEE 2920
ARM M4 Peripherals
• Systick – Calibration Register SysTick -> CALIB
![Page 11: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/11.jpg)
11 © tjEE 2920
ARM M4 Peripherals
• SysTick Exampleint Delay_48MHz_us(uint32_t val){
// input checking// max input is 349,524if (val > 349524){
printf("\nDelay_48MHz_us delay out of bounds %i\n", val);exit(1);
}
// Local Variables// These values are used to timeout the transitionsuint32_t delay_cnt;
// Calculate the required number of clock cycles// 48MHz --> 20.8333ns/clk// # of clocks per us = 1e-6 * 48e6 = 48// required number of clocks = val * clks/usdelay_cnt = val * 48;
// Setup the systick timerSysTick->CTRL = 0x0005; // set clk to CPU clk (bit 2) and enable (bit 0)SysTick->LOAD = delay_cnt;SysTick->VAL = 0x0;
// Waitwhile(!(SysTick->CTRL & 0x00010000));
// Done waitingreturn 0;} // end Delay_48MHz_us
![Page 12: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/12.jpg)
12 © tjEE 2920
ARM M4 Peripherals
• System Control Block – SCB
• Access to a range of system level registers
![Page 13: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/13.jpg)
13 © tjEE 2920
ARM M4 Peripherals
• SCB - Registers
SCB->CPUID…
SCB->SHP[1] – SHP[3]
SCB->PFR[0 – PFR[1]
SCB->MMFR[0 – MMFR[3]
SCB>ISAR[0] - ISAR[4]
![Page 14: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/14.jpg)
14 © tjEE 2920
ARM M4 Peripherals
• SCB – CPU ID RegisterSCB->CPUID
![Page 15: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/15.jpg)
15 © tjEE 2920
ARM M4 Peripherals
• SCB – Interrupt Control State Register
…
SCB->ICSR
![Page 16: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/16.jpg)
16 © tjEE 2920
ARM M4 Peripherals
• Memory Protection Unit – MPU
• The MPU breaks the processor memory into 8 logical regions
• Each region has settings to:• Set start address and size
• Limit access (privilege)
• Set as bufferable
• Set as cacheable
• Set as non-executable
![Page 17: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/17.jpg)
17 © tjEE 2920
ARM M4 Peripherals
• MPU - Privilege• Program memory, data memory, and peripheral access
limitations
• Operating System (privileged)• Access to all of program memory and data memory• Access to all peripherals
• Application Program A (unprivileged)• Access to portions of program memory and data memory• Access to some peripherals
• Application Program B (unprivileged)• Access to portions of program memory and data memory• Access to some peripherals
![Page 18: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/18.jpg)
18 © tjEE 2920
ARM M4 Peripherals
• MPU - Registers MPU->TYPE…
![Page 19: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/19.jpg)
19 © tjEE 2920
ARM M4 Peripherals
• Floating Point Unit – FPU• 32-bit instructions for single-precision (C float) data-
processing operations
• Combined multiply and accumulate instructions for increased precision (Fused MAC)
• Hardware support for conversion, addition, subtraction, multiplication with optional accumulate, division, and square root
• Hardware support for denormals and all IEEE rounding modes
• 32 dedicated 32-bit single-precision registers, also addressable as 16 double-word registers
• Decoupled three stage pipeline
![Page 20: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/20.jpg)
20 © tjEE 2920
ARM M4 Peripherals
• Floating Point Unit – FPU• Extended Register Set• Sixteen 64-bit double-word registers, D0-D15
• Thirty-two 32-bit single-word registers, S0-S31
• A combination of registers from the above views
• The FPU is disabled from reset. You must enable it before you can use any floating-point instructions.• In many compilers, such as in TI's Code Composer Studio IDE, if the
hardware FPU option is selected in the compiler setting, the initialization code enables the FPU before entering the main() function. In this case, users do not need to manually turn on the FPU in the main application code.
• The processor must be in privileged mode to read from and write to the Coprocessor Access Control (CPAC) register – see the spec for details
![Page 21: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/21.jpg)
21 © tjEE 2920
ARM M4 Peripherals
• Floating Point Unit – Registers
FPU->FPCCR…FPU->MVFR1
![Page 22: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/22.jpg)
22 © tjEE 2920
ARM M4 Peripherals
• Debug Peripherals• FPB - Flash Patch and Breakpoint• Causes flashed code to be re-directed to a different location
• Causes flashed code to cause a breakpoint in hardware
• DWT – Data Watchpoint and Trace• Hardware triggers
• Data Address triggers
• PC Sampler Triggers
• ITM – Instrumentation Trace Macrocell
TPIU – Trace Port Interface Unit• Provide printf style debugging to an output stream
• JTAG – Joint Test Action Group
SWD – Serial Wire Debug• Access to the debug peripherals
![Page 23: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/23.jpg)
23 © tjEE 2920
ARM M4 Peripherals
![Page 24: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/24.jpg)
24 © tjEE 2920
Watchdog Timer
• Basic Watchdog Function
• What happens if your code gets trapped in a loop or runs off into the weeds?
• Checks to make sure your software is running
• Count up timer that creates a system reset if it gets to a programmed value
• System software must periodically reset the timer to prevent it from activating a system reset
![Page 25: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/25.jpg)
25 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer• ARM (AMBA Compliant) timer
• 32 bit timer
• Password protected• Any violation results in a
system reset
• Can be configured as an
interval counter
• COUNT UP TIMER
![Page 26: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/26.jpg)
26 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer
![Page 27: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/27.jpg)
27 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer
• Password Protection• 16 bit control register
• Uses special instruction to access
• Upper byte must be 0x5A (password) for writes
• Upper byte returns 0x69 for reads
• Any incorrect instruction access → system reset
• Any incorrect password → system reset
![Page 28: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/28.jpg)
28 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer
• Reset Defaults• WD Timer not active
• Count set to 215
• Clock source set to SMCLK
![Page 29: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/29.jpg)
29 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer
• Interval Timer Mode• Count up counter
• Sets a flag or creates an interrupt when the programmed count is reached
![Page 30: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/30.jpg)
30 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer
• Watchdog Control Register WDT_A->CTL
![Page 31: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/31.jpg)
31 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer• Watchdog Control Register
![Page 32: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/32.jpg)
32 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer• Example
/** wdt_example.c** Created on: Jul 24, 2018* Author: johnsontimoj*/
///////////////////////////// example file for showing watch dog timer operation//// kills a counting program after a period of time//// inputs: none// outputs: count and failure/////////////////////////////
// includes#include "msp.h"#include <stdio.h>
int main(void){
// setup watchdog// 0101 1010 0 0 0 0 010// password hold off sm clk wd mode no clr 2**23 cnts(~8M clocks)WDT_A->CTL = 0x5A02;
int i;for(i = 0; i<20; i++){
printf("count is %i\n", i);__delay_cycles(1000000);
}
return 0;}
WD Timer resetsthe processor
![Page 33: ARM M4 Peripherals - Milwaukee School of Engineering](https://reader030.vdocument.in/reader030/viewer/2022021120/6205dbba0ad58434ce5e0798/html5/thumbnails/33.jpg)
33 © tjEE 2920
Watchdog Timer
• MSP432 Watchdog Timer• Example // includes
#include "msp.h"#include <stdio.h>
int main(void){
// setup watchdog// 0101 1010 0 0 0 0 010// password hold off sm clk wd mode no clr 2**23 cnts(~8M clocks)WDT_A->CTL = 0x5A02;
int i;for(i = 0; i<20; i++){
// clear timer// returns 0x69xx, need to write 0x5Ax(1bbb)// turn off bits 1 in 6, 0 in 9// turn on bits 0 in 5, bit 1 in A// turn on bit 3 in lsb nibbleWDT_A->CTL = (WDT_A->CTL & ~0x2100) | 0x1208;
printf("count is %i\n", i);__delay_cycles(1000000);
}
return 0;}
Resets the WD timer