Commit Graph

8 Commits

Author SHA1 Message Date
robert-hh 20e7313453 samd/clock_config: Add HW_DFLL_USB_SYNC and HW_MCU_OSC32KULP extensions.
Two new compile flags are:

MICROPY_HW_DFLL_USB_SYNC: Effective only if DFLL48 does not run from the
crystal.  It will synchronize the DFLL48M clock with the USB's SOF pulse.
If no USB is connected, it will fall back to open loop mode.  The DFLL48M
clock is then pretty precise, but with a higher clock jitter at SAMD51
devices.

MICROPY_HW_MCU_OSC32KULP: Effective only if the devics uses a crystal as
clock source.  Run the MCU clock from the ULP 32kHz oszillator instead of
the crystal.  This flag was added to cater for a interference problem of
the crystal and Neopixel/Debug pins at Adafruit FEATHER Mx boards, which
causes the board to crash.  Drawback: ticks_ms() and time.time() vs. than
ticks_us() and the peripherals like PWM run at not synchronous clocks.
2022-10-06 23:03:08 +11:00
robert-hh a415752173 samd/machine_bitstream: Add the machine.bitstream() function.
The SAMD21 implementation is an adaption of @jimmo's code for STM32Lxx.
The only changes are the addresses and names of the port registers and the
timing parameters.

SAMD21: The precision is about +/-25ns at 48MHz clock frequency.  The first
two cycles are about 40-60 ns longer than set.  But still good enough to
drive a neopixel device.

SAMD51: The precision is about +/-30ns at 120MHz clock frequency.  Good
enough to drive a neopixel device.
2022-10-06 23:00:00 +11:00
robert-hh fd7b57dd22 samd/mphalport: Use CYCCNT for SAMD51's mp_hal_ticks_cpu().
And use mp_hal_ticks_us() for SAM21's mp_hal_ticks_cpu().  The SAMD21 has
no CYCCNT register, and the SysTick register has only a 1 ms span (== 48000
count range).
2022-10-06 22:59:02 +11:00
robert-hh b4d29fd47a samd/clock_config: Set up the clock configuration.
Clock settings:
- GCLK0: 48 MHz (SAMD21) or 120 MHz(SAMD51).
- GCLK1: 32768 Hz for driving the PLL.
- GCLK2: 48 MHz for tzhe peripheral clock.
- GCLK3: 1 MHz (SAMD21) or 8 MHz (SAMD51) for the µs ticks timer.
- GCLK8: 1 kHz for WDT (SAMD21 only).

If a 32 kHz crystal is present, it will be used as clock source.  Otherwise
the DFLL48M in open-loop mode is used.

GCLK0 for SAM51 can be changed between 48 MHz and 200 MHz.  The specified
range is 96 MHz - 120 MHz.
2022-10-06 22:33:31 +11:00
robert-hh 85afed569d samd: Remove the existing provisional support for REPL on UART.
It was only partially working and will be rpelaced later by a full
machine.UART class implementation.
2022-10-06 22:29:06 +11:00
Peter van der Burg 4c132614e1 samd/samd_soc: Allow a board to configure the low-level MCU config.
The board specific #defines will be moved to individual boards.
2021-11-19 11:42:47 +11:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George 5f9bd11527 samd: Add new port to Microchip SAMDxx microcontrollers.
Initially supporting SAMD21 and SAMD51.
2019-07-01 17:19:18 +10:00