Skip to content

Commit

Permalink
firmware: add definition for main osc bypass when using external osc
Browse files Browse the repository at this point in the history
Add new board.h definition BOARD_MAINOSC_BYPASS to configure the clock module to use an external oscillator rather than a crystal. The qmod board is one such board.
Change-Id: If62f55cd4c8b0cf758534f09d25a9bcb028814a7
  • Loading branch information
James Tavares authored and laf0rge committed Jan 11, 2022
1 parent aeaf128 commit 91a93bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions firmware/libboard/common/source/board_lowlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ extern WEAK void LowLevelInit( void )
}
*/

#ifndef qmod
#ifndef BOARD_MAINOSC_BYPASS
/* Initialize main oscillator */
if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
{
Expand All @@ -165,11 +165,11 @@ extern WEAK void LowLevelInit( void )
timeout = 0;
while (!(PMC->PMC_SR & PMC_SR_MOSCSELS) && (timeout++ < CLOCK_TIMEOUT));
#else
/* QMOD has external 12MHz clock source */
/* Board has external clock, not a crystal oscillator */
PIOB->PIO_PDR = (1 << 9);
PIOB->PIO_PUDR = (1 << 9);
PIOB->PIO_PPDDR = (1 << 9);
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTBY| CKGR_MOR_MOSCSEL;
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTBY | CKGR_MOR_MOSCSEL;
#endif

/* disable the red LED after main clock initialization */
Expand Down
4 changes: 3 additions & 1 deletion firmware/libboard/qmod/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define BOARD_MAINOSC 12000000
/** desired main clock frequency (in Hz, based on BOARD_MAINOSC) */
#define BOARD_MCK 58000000 // 18.432 * 29 / 6
/** board has external clock, not crystal */
#define BOARD_MAINOSC_BYPASS

/** MCU pin connected to red LED */
#define PIO_LED_RED PIO_PA17
Expand All @@ -35,7 +37,7 @@
/** green LED pin definition */
#define PIN_LED_GREEN {PIO_LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
/** LEDs pin definition */
#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
/** index for red LED in LEDs pin definition array */
#define LED_NUM_RED 0
/** index for green LED in LEDs pin definition array */
Expand Down

0 comments on commit 91a93bc

Please sign in to comment.