summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authormwachs5 <megan@sifive.com>2017-06-13 20:19:02 -0700
committermwachs5 <megan@sifive.com>2017-06-13 20:32:25 -0700
commite8938ea7fa90cea0f17460ef35ee00cdcb81aea3 (patch)
tree386f872828b57ab27240a5d767c487533b2d780e /software
parentdecb0968a3f12ae29def0b391f5386f26f4ba280 (diff)
led_fade: make sure the HFROSC is running before you try to use it.
Diffstat (limited to 'software')
-rw-r--r--software/led_fade/led_fade.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/software/led_fade/led_fade.c b/software/led_fade/led_fade.c
index 3c7b8c8..9b50eda 100644
--- a/software/led_fade/led_fade.c
+++ b/software/led_fade/led_fade.c
@@ -68,11 +68,14 @@ static void _puts(const char * s) {
int main (void){
- // Run off 16 MHz Crystal for accuracy.
+ // Make sure the HFROSC is on before the next line:
+ PRCI_REG(PRCI_HFROSCCFG) |= ROSC_EN(1);
+ // Run off 16 MHz Crystal for accuracy. Note that the
+ // first line is
PRCI_REG(PRCI_PLLCFG) = (PLL_REFSEL(1) | PLL_BYPASS(1));
PRCI_REG(PRCI_PLLCFG) |= (PLL_SEL(1));
// Turn off HFROSC to save power
- PRCI_REG(PRCI_HFROSCCFG) = 0;
+ PRCI_REG(PRCI_HFROSCCFG) &= ~(ROSC_EN(1));
// Configure UART to print
GPIO_REG(GPIO_OUTPUT_VAL) |= IOF0_UART0_MASK;