arm:atsamc21
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| arm:atsamc21 [2021/01/05 14:03] – [GCLK, Generic Clock system] utedass | arm:atsamc21 [2022/09/12 00:30] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 45: | Line 45: | ||
| ===== Clocks and synchronisation ===== | ===== Clocks and synchronisation ===== | ||
| At startup the clock is configured to 4 MHz. | At startup the clock is configured to 4 MHz. | ||
| + | |||
| + | The initial clock setup is described in chapter 15.7 and chapter 12. | ||
| All peripherals interfaces two different clock-domains; | All peripherals interfaces two different clock-domains; | ||
| Line 55: | Line 57: | ||
| Each core register has its own synchronization mechanism, which makes it possible to write to different core registers consecutively without problems. | Each core register has its own synchronization mechanism, which makes it possible to write to different core registers consecutively without problems. | ||
| - | |||
| - | The initial clock setup is described in chapter 15.7 and chapter 12. | ||
| Maximum clock frequencies for different parts of the controller can be found in table 45-8 in chapter 45.6. | Maximum clock frequencies for different parts of the controller can be found in table 45-8 in chapter 45.6. | ||
| ==== MCLK, Main Clock system ==== | ==== MCLK, Main Clock system ==== | ||
| - | Examples | + | Three equivalent examples |
| <code c> | <code c> | ||
| MCLK-> | MCLK-> | ||
| Line 86: | Line 86: | ||
| Example of how to hook up TC0 to Generator 2 | Example of how to hook up TC0 to Generator 2 | ||
| <code c> | <code c> | ||
| - | GCLK.GENCTRL[2].reg = GCLK_GENCTRL_DIV(100) | GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC(GCLK_GENCTRL_SRC_OSC48M_Val); | + | GCLK->GENCTRL[2].reg = GCLK_GENCTRL_DIV(100) | GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC(GCLK_GENCTRL_SRC_OSC48M_Val); |
| - | GCLK.PCHCTRL[TC0_GCLK_ID].bit.CHEN = GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN(GCLK_PCHCTRL_GEN_GCLK2_Val); | + | GCLK->PCHCTRL[TC0_GCLK_ID].bit.CHEN = GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN(GCLK_PCHCTRL_GEN_GCLK2_Val); |
| </ | </ | ||
| ===== Step-by-step ===== | ===== Step-by-step ===== | ||
| Line 216: | Line 216: | ||
| </ | </ | ||
| + | ====== CAN Bus Peripheral ====== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | |||
| + | '' | ||
| ====== Programming ====== | ====== Programming ====== | ||
| Good place: [[https:// | Good place: [[https:// | ||
| Line 237: | Line 243: | ||
| <code batch> | <code batch> | ||
| $ arm-none-eabi-gdb main.elf --eval-command=" | $ arm-none-eabi-gdb main.elf --eval-command=" | ||
| + | </ | ||
| + | |||
| + | |||
| + | A file named '' | ||
| + | <code tcl> | ||
| + | # Filename: openocd.cfg | ||
| + | # or envoke with openocd -f filename.cfg | ||
| + | |||
| + | # Explicit debugger and target config files | ||
| + | #source [find interface/ | ||
| + | #source [find target/ | ||
| + | |||
| + | # Readily available config instead of the explicit setup above | ||
| + | source [find board/ | ||
| + | |||
| + | # Some of the sleep commands seems necessary, otherwise the MCU doesnt seem to react properly | ||
| + | |||
| + | # Set to known state | ||
| + | init | ||
| + | reset init | ||
| + | sleep 25 | ||
| + | |||
| + | # Erase flash | ||
| + | at91samd chip-erase | ||
| + | sleep 25 | ||
| + | |||
| + | # Write firmware | ||
| + | flash write_bank 0 flash_image.bin 0 | ||
| + | sleep 25 | ||
| + | |||
| + | # Reset MCU | ||
| + | reset | ||
| + | sleep 25 | ||
| + | |||
| + | # Shut down openocd server | ||
| + | shutdown | ||
| + | sleep 25 | ||
| </ | </ | ||
| ====== Getting started ====== | ====== Getting started ====== | ||
arm/atsamc21.1609855417.txt.gz · Last modified: 2022/09/12 00:30 (external edit)
