示例#1
0
/**************************************************************************//**
 * @brief Main function
 *****************************************************************************/
int main(void)
{  
  /* Chip revision alignment and errata fixes */
  CHIP_Init();
  
  /* Set system frequency to 1 MHz */
  CMU_HFRCOBandSet(cmuHFRCOBand_1MHz);
  
  /* Initialize LCD */
  SegmentLCD_Init(false); 

  /* Initialize TIMER0 */
  initTimer();
  
  /* Enable Sleep-om-Exit */
  SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
  
  /* Initialize interrupt count */
  interruptCount = 0;
  
  /* Enter EM1 until all TIMER0 interrupts are done
   * Notice that we only enter sleep once, as the MCU will fall asleep
   * immediately when the ISR is done without returning to main as long as
   * SLEEPONEXIT is set */
  EMU_EnterEM1();
  
  /* Signal that program is done */
  SegmentLCD_Write("DONE");
  while(1);
}
示例#2
0
/**************************************************************************//**
 * @brief  Main function of clock example.
 *
 *****************************************************************************/
int main(void)
{  
  EMSTATUS status;
  bool redraw;
  ClockMode_t prevClockMode = CLOCK_MODE_DIGITAL;
  
  /* Chip errata */
  CHIP_Init();

  /* Use the 21 MHz band in order to decrease time spent awake.
     Note that 21 MHz is the highest HFRCO band on ZG. */
  CMU_ClockSelectSet( cmuClock_HF, cmuSelect_HFRCO  );
  CMU_HFRCOBandSet( cmuHFRCOBand_21MHz );

  /* Setup GPIO for pushbuttons. */
  gpioSetup();

  /* Initialize display module */    
  status = DISPLAY_Init();
  if (DISPLAY_EMSTATUS_OK != status)
    while (true)
      ;

  /* Initialize the DMD module for the DISPLAY device driver. */
  status = DMD_init(0);
  if (DMD_OK != status)
    while (true)
      ;

  status = GLIB_contextInit(&gc);
  if (GLIB_OK != status)
    while (true)
      ;
  
  /* Set PCNT to generate interrupt every second */
  pcntInit();
  
  /* Pre-compte positions for the analog graphics */
  analogClockInitGraphics();

  /* Enter infinite loop that switches between analog and digitcal clock
   * modes, toggled by pressing the button PB0. */
  while (true)
  {    
    redraw = (prevClockMode != clockMode);
    prevClockMode = clockMode;
    if (CLOCK_MODE_ANALOG == clockMode)
    {
      analogClockShow(redraw);
    }
    else
    {
      digitalClockShow(redraw);
    }
    /* Sleep between each frame update */
    EMU_EnterEM2(false);
  }
}
/*
 * Function Name: main();
 * Description: All the function calls are done in main(). The CPU goes to sleep while in main(); until Interupt is generated.
 */
int main(void)
{

    CHIP_Init();

    CMU_HFRCOBandSet(cmuHFRCOBand_14MHz);
    CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
    CMU_OscillatorEnable(cmuOsc_HFXO, false, false);

    blockSleepMode(EM2); //Prevents the CPU to go below EM3 mode.

#if DEBUG_ON
    BSP_TraceSwoSetup(); //For simplicity studio Energy profiler code correlation.
#endif
    LETIMER_setup(); //Initialize LETIMER.

    ADC_Setup(); //Initialize the ADC

    DMA_Init();	//Initialize DMA.

    DMA_Setup(); //Setup DMA.

    LEUART_Setup(); //Initialize LEUART.

    GPIO_Init(); //Initialize GPOIs.

    LETIMER_IntEnable(LETIMER0, LETIMER_IF_UF); //Enable underflow UF interrupt.

    LEUART_IntEnable(LEUART0, LEUART_IF_SIGF);	// Enable SF RXDATAV

    NVIC_EnableIRQ(LETIMER0_IRQn); //Enable LETIMER0 interrupt vector in NVIC (Nested Vector Interrupt Controller)

    NVIC_EnableIRQ(LEUART0_IRQn); //Enable LETIMER0 interrupt vector in NVIC (Nested Vector Interrupt Controller)

	LEUART0->SIGFRAME = '!';							// Set LEUART signal frame to '!'

	LEUART0->CTRL |= LEUART_CTRL_RXDMAWU;				// Enable DMA wake up for LEUART RX in EM2
    DMA_ActivateBasic(DMA_CHANNEL_RX, true, false, (void *)RX_Buffer, (void *)&(LEUART0->RXDATA), LEUART0_BUFFER-1);

    // Enable Sleep-on-Exit
#if SLEEPONEXIT
    SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;	// Setting the corresponding bit for SleepOnExit
#endif

    while(1)
    {
        sleep(); //CPU goes to EM3 Mode to save energy, waits there until Interrupt is generated.
    }

}
void __efm32lg_mcu_init()
{
    /* Chip errata */
    CHIP_Init();


#ifdef HW_USE_HFXO
    // init clock with HFXO (external)
    CMU_ClockDivSet(cmuClock_HF, cmuClkDiv_2);		// 24 MHZ
    CMU_OscillatorEnable(cmuOsc_HFXO, true, true);   // Enable XTAL Osc and wait to stabilize
    CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO); // Select HF XTAL osc as system clock source. 48MHz XTAL, but we divided the system clock by 2, therefore our HF clock will be 24MHz
    //CMU_ClockDivSet(cmuClock_HFPER, cmuClkDiv_4); // TODO set HFPER clock divider (used for SPI) + disable gate clock when not used?
#else
    // init clock with HFRCO (internal)
    CMU_HFRCOBandSet(cmuHFRCOBand_21MHz);
    CMU_OscillatorEnable(cmuOsc_HFRCO, true, true);
    CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
#endif

    uint32_t hf = CMU_ClockFreqGet(cmuClock_HF);
}
示例#5
0
文件: cpu.c 项目: mathirkub/RIOT
static void cpu_clock_init(void)
{
    SystemLFXOClockSet((uint32_t)EFM32_LFXO_FREQ);
	CMU_OscillatorEnable(cmuOsc_LFXO, true, true);
	CMU_OscillatorEnable(cmuOsc_HFRCO, true, true);
	CMU_HFRCOBandSet(cmuHFRCOBand_28MHz);
//	/* HF Core clock is connected to external oscillator */
//	CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);
	/* HF Core clock is connected to internal RC clock */
	CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
	/* RTC, LESENSE, LETIMER0, LCD is connected to external 36kHz oscillator */
	CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
	CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFXO);
	/* HFPER clock is divided by 2 - 14MHz */
	CMU_ClockDivSet(cmuClock_HFPER, cmuClkDiv_2);
	/* core, DMA etc. clock */
	CMU_ClockDivSet(cmuClock_CORE, cmuClkDiv_1);
	/* enabling clocks */
	CMU_ClockEnable(cmuClock_HFPER, true);
	CMU_ClockEnable(cmuClock_CORELE, true);
}
示例#6
0
/**************************************************************************//**
 * @brief Energy Mode 1 demonstration, no active peripherals
 * @param[in] clock Select oscillator to use
 * @param[in] HFRCO band
 *****************************************************************************/
void Demo_EM1(CMU_Select_TypeDef clock, CMU_HFRCOBand_TypeDef band)
{
  /* Disable systick timer */
  SysTick->CTRL  = 0;

  /* Set HF clock  */
  CMU_ClockSelectSet(cmuClock_HF, clock);

  /* If HFRCO, select band */
  if(clock == cmuSelect_HFRCO)
  {
    CMU_HFRCOBandSet(band);
  }

  /* Disable HFRCO, LFRCO and all unwanted clocks */
  if(clock != cmuSelect_HFXO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_HFXODIS;
  }
  if(clock != cmuSelect_HFRCO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_HFRCODIS;
  }
  if(clock != cmuSelect_LFRCO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_LFRCODIS;
  }
  if(clock != cmuSelect_LFXO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_LFXODIS;
  }
  CMU->HFPERCLKEN0  = 0x00000000;
  CMU->HFCORECLKEN0 = 0x00000000;
  CMU->LFACLKEN0    = 0x00000000;
  CMU->LFBCLKEN0    = 0x00000000;

  /* Enter Energy Mode 1, no active peripherals */
  EMU_EnterEM1();
}
/**************************************************************************//**
 * @brief Main function
 *****************************************************************************/
int main(void)
{
  
  /* Chip revision alignment and errata fixes */
  CHIP_Init();
    
  /* Set the clock frequency to 11MHz so the ADC can run on the undivided HFCLK */
  CMU_HFRCOBandSet(cmuHFRCOBand_11MHz);
  
  /* Configure RTC to use LFRCO as clock source */
  RTC_Setup(cmuSelect_LFRCO);
    
  /* Configure ADC */
  ADC_Config();
 
  /* Start ADC sampling, adcFinished is set when sampling is finished. */
  /* It is safe to do other stuff or go to EM2 while adc sampling is active. */
  /* ADC sampling uses the RTC to trigger new samples. */
  startAdcSampling();
    
  /* Wait in EM2 until adc sampling is finished. */
  /* Disable interrupts until flag is checked in case loop finishes after flag 
  * check but before sleep command. Device will still wake up on any set IRQ 
  * and any pending interrupts will be handled after interrupts are enabled 
  * again. */
  INT_Disable();
  while(!adcFinished)
  {
   EMU_EnterEM2(false); 
   INT_Enable();
   INT_Disable();
  }
  INT_Enable();    
  
  /* Finished */
  while(1);
  
}  
示例#8
0
/**************************************************************************//**
 * @brief main - the entrypoint after reset.
 *****************************************************************************/
int main(void)
{
  /* Initialize LEUSB state variables */
  leusbTogglePushed = false;
  leusbEnabled = false;
  refreshDisplay = false;

  HIDKBD_Init_t hidInitStruct;

  /* Chip errata */
  CHIP_Init();

  /* Go slow to reduce current consumption. */
  CMU_HFRCOBandSet( cmuHFRCOBand_7MHz );

  CMU_ClockEnable( cmuClock_GPIO, true );
  GPIO_PinModeSet( BUTTON0_PORT, BUTTON0_PIN, gpioModeInputPull, 1 );
  GPIO_PinModeSet( BUTTON1_PORT, BUTTON1_PIN, gpioModeInputPull, 1 );

  /* Initialize the display module. */
  DISPLAY_Init();

  /* Retrieve the properties of the display. */
  if ( DISPLAY_DeviceGet( 0, &displayDevice ) != DISPLAY_EMSTATUS_OK )
  {
    /* Unable to get display handle. */
    while( 1 );
  }

  memset( (void*)blank_image, 0xFF, 128*16 );
  displayDevice.pPixelMatrixDraw( &displayDevice, (void*)blank_image,
                                  /* start column, width */
                                  0, displayDevice.geometry.width,
                                  /* start row, height */
                                  0, displayDevice.geometry.height);
  scrollLcd( &displayDevice, scrollLeft, blank_image, gecko_image );

  /* Initialize HID keyboard driver. */
  hidInitStruct.hidDescriptor = (void*)USBDESC_HidDescriptor;
  hidInitStruct.setReportFunc = NULL;
  HIDKBD_Init( &hidInitStruct );

  /* Initialize and start USB device stack. */
  USBD_Init( &usbInitStruct );

  /* Turn off the Low Energy Mode (LEM) features that were enabled in USBD_Init() */
  USB->CTRL &= ~USB_CTRL_LEMIDLEEN;	// LEUSB off to begin demo

  /*
   * When using a debugger it is practical to uncomment the following three
   * lines to force host to re-enumerate the device.
   */
  /* USBD_Disconnect();      */
  /* USBTIMER_DelayMs(1000); */
  /* USBD_Connect();         */

  for (;;)
  {
    if (refreshDisplay)
    {
      refreshDisplay = false; /* Clear the "refresh display" flag */
      if (leusbEnabled)
      {
        /* Update the LCD image to reflect USB Low Energy Mode enabled */
        displayDevice.pPixelMatrixDraw( &displayDevice, (void*)leusb_image,
                                        /* start column, width */
                                        0, displayDevice.geometry.width,
                                        /* start row, height */
                                        0, displayDevice.geometry.height);
      }
      else
      {
        /* Update the LCD image to reflect normal USB HID keyboard demo status */
        displayDevice.pPixelMatrixDraw( &displayDevice, (void*)usb_image,
                                        /* start column, width */
                                        0, displayDevice.geometry.width,
                                        /* start row, height */
                                        0, displayDevice.geometry.height);
      }
    }
    /* Conserve energy ! */
    EMU_EnterEM1();
  }
}
示例#9
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  int   value, delayCount = 0, hfrcoband = 0;
  float current, voltage;
  bool  vboost;
  char  buffer[8];

  /* Chip errata */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Initialize board support package */
  BSP_Init(BSP_INIT_BCC);

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(SystemCoreClockGet() / 1000)) while (1) ;

  /* Initialize voltage comparator, to check supply voltage */
  VDDCHECK_Init();

  /* Check if voltage is below 3V, if so use voltage boost */
  if (VDDCHECK_LowVoltage(2.9))
  {
    vboost = true;
  }
  else
  {
    vboost = false;
  }

  /* Disable Voltage Comparator */
  VDDCHECK_Disable();

  /* Initialize segment LCD */
  SegmentLCD_Init(vboost);

  /* Infinite loop */
  while (1)
  {
    /* Read and display current */
    current = BSP_CurrentGet();
    value   = (int)(1000 * current);

    /* Check that we fall within displayable value */
    if ((value > 0) && (value < 10000))
    {
      SegmentLCD_Number(value);
    }
    else
    {
      SegmentLCD_Number(-1);
    }

    /* Alternate between voltage and clock frequency */
    if (((delayCount / 10) & 1) == 0)
    {
      voltage = BSP_VoltageGet();
      value   = (int)(voltage * 100);
      SegmentLCD_Symbol(LCD_SYMBOL_DP6, 1);
      sprintf(buffer, "Volt%3d", value);
      SegmentLCD_Write(buffer);
    }
    else
    {
      SegmentLCD_Symbol(LCD_SYMBOL_DP6, 0);
      sprintf(buffer, "%3u MHz", (int)(SystemCoreClockGet() / 1000000));
      SegmentLCD_Write(buffer);
    }
    /* After 5 seconds, use another HFRCO band */
    if (delayCount % 50 == 0)
    {
      switch (hfrcoband)
      {
      case 0:
        CMU_HFRCOBandSet(cmuHFRCOBand_11MHz);
        break;
      case 1:
        CMU_HFRCOBandSet(cmuHFRCOBand_14MHz);
        break;
      case 2:
        CMU_HFRCOBandSet(cmuHFRCOBand_21MHz);
        break;
      default:
        CMU_HFRCOBandSet(cmuHFRCOBand_28MHz);
        /* Restart iteartion */
        hfrcoband = -1;
        break;
      }
      hfrcoband++;
      /* Recalculate delay tick count and baudrate generation */
      if (SysTick_Config(SystemCoreClockGet() / 1000)) while (1) ;
      BSP_Init(BSP_INIT_BCC);
    }

    Delay(100);
    delayCount++;
  }
}
示例#10
0
/**************************************************************************//**
 * @brief Run demo calculating prime numbers at given clock frequency
 * @param[in] clock Select oscillator to use
 * @param[in] HFRCO band
 *****************************************************************************/
void Demo_Primes(CMU_Select_TypeDef clock, CMU_HFRCOBand_TypeDef band)
{
  /* Disable systick timer */
  SysTick->CTRL  = 0;

  /* Set HF clock  */
  CMU_ClockSelectSet(cmuClock_HF, clock);

  /* If HFRCO, select band */
  if(clock == cmuSelect_HFRCO)
  {
    CMU_HFRCOBandSet(band);
  }

  /* Disable HFRCO, LFRCO and all unwanted clocks */
  if(clock != cmuSelect_HFXO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_HFXODIS;
  }
  if(clock != cmuSelect_HFRCO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_HFRCODIS;
  }
  if(clock != cmuSelect_LFRCO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_LFRCODIS;
  }
  if(clock != cmuSelect_LFXO)
  {
    CMU->OSCENCMD = CMU_OSCENCMD_LFXODIS;
  }

  /* Disable peripheral clocks */
  CMU->HFPERCLKEN0  = 0x00000000;
  CMU->HFCORECLKEN0 = 0x00000000;
  CMU->LFACLKEN0    = 0x00000000;
  CMU->LFBCLKEN0    = 0x00000000;
  {
#define PRIM_NUMS 64
    uint32_t i, d, n;
    uint32_t primes[PRIM_NUMS];

    /* Find prime numbers forever */
    while (1)
    {
      primes[0] = 1;
      for (i = 1; i < PRIM_NUMS;)
      {
        for (n = primes[i - 1] + 1; ;n++)
        {
          for (d = 2; d <= n; d++)
          {
            if (n == d)
            {
              primes[i] = n;
              goto nexti;
            }
            if (n%d == 0) break;
          }
        }
      nexti:
        i++;
      }
    }
  }
}
示例#11
0
/**************************************************************************//**
 * The main entry point.
 *****************************************************************************/
int main(void)
{
  int msElapsed, i;

  /* Set new vector table pointer */
  SCB->VTOR = 0x20000000;

  /* Enable peripheral clocks. */
  CMU->HFPERCLKDIV = CMU_HFPERCLKDIV_HFPERCLKEN;
  CMU->HFPERCLKEN0 = CMU_HFPERCLKEN0_GPIO | BOOTLOADER_USART_CLOCK |
                     AUTOBAUD_TIMER_CLOCK ;

  /* Enable DMA interface */
  CMU->HFCORECLKEN0 = CMU_HFCORECLKEN0_DMA;

#if defined( BL_DEBUG )
  RETARGET_SerialInit();        /* Setup debug serialport etc. */
  USB_PUTS( "EFM32 USB/USART0 bootloader\r\n" );
#endif

  /* Calculate CRC16 for the bootloader itself and the Device Information page. */
  /* This is used for production testing and can safely be omitted in */
  /* your own code. */
  bootloaderCRC  = CRC_calc((void *) 0x0, (void *) BOOTLOADER_SIZE);
  bootloaderCRC |= CRC_calc((void *) 0x0FE081B2, (void *) 0x0FE08200) << 16;

  StartRTC();

#if !defined( SIMULATE_SWDCLK_PIN_HI )
  while ( SWDCLK_PIN_IS_LO() )
  {
    USB_PUTS( "SWDCLK is low\r\n" );

    if ( BOOT_checkFirmwareIsValid() )
    {
      USB_PUTS( "Booting application\r\n  " );
      BOOT_boot();
    }
    else
    {
      USB_PUTS( "No valid application, resetting EFM32... \r\n" );

      /* Go to EM2 and wait for RTC wakeup. */
      EMU_EnterEM2( false );
    }
  }
#endif

  NVIC_DisableIRQ( RTC_IRQn );

  /* Try to start HFXO. */

  CMU_OscillatorEnable( cmuOsc_HFXO, true, false );

  /* Wait approx. 1 second to see if HFXO starts. */
  i = 1500000;
  while ( i && !( CMU->STATUS & CMU_STATUS_HFXORDY ) )
  {
    i--;
  }

  USBTIMER_Init();

  if ( i == 0 )
  {
    CMU_HFRCOBandSet( cmuHFRCOBand_28MHz );
  }
  else
  {
    CMU_ClockSelectSet( cmuClock_HF, cmuSelect_HFXO );
    USBD_Init( &initstruct );       /* Start USB CDC functionality  */
  }

  AUTOBAUD_start();                 /* Start autobaud               */

  /* Wait 30 seconds for USART or USB connection */
  msElapsed = 0;
  while ( msElapsed < 30000 )
  {
    if ( AUTOBAUD_completed() )
      break;

    if ( CDC_Configured )
    {
      BOOTLDIO_setMode( CDC_Configured );
      break;
    }

    USBTIMER_DelayMs( 100 );
    msElapsed += 100;
  }
  AUTOBAUD_stop();

  if ( msElapsed >= 30000 )
  {
    USB_PUTS( "USART0/USB timeout, resetting EFM32...\r\n  " );
    Disconnect( 0, 2000 );
    SCB->AIRCR = 0x05FA0004;        /* Reset EFM32. */
  }

  /* Print a message to show that we are in bootloader mode */
  BOOTLDIO_printString("\r\n\r\n" BOOTLOADER_VERSION_STRING );

  /* Print the chip ID. This is useful for production tracking */
  BOOTLDIO_printHex(DEVINFO->UNIQUEH);
  BOOTLDIO_printHex(DEVINFO->UNIQUEL);
  BOOTLDIO_printString("\r\n");

  /* Figure out correct flash geometry. */
  FLASH_CalcPageSize();
  /* Initialize flash for writing */
  FLASH_init();

  /* Start executing command line */
  commandlineLoop();
}
示例#12
0
int main(void)
{
  CHIP_Init();

  // Enable clocks
  CMU_ClockEnable(cmuClock_EBI, true);
  CMU_ClockEnable(cmuClock_GPIO, true);

  CMU_HFRCOBandSet(cmuHFRCOBand_28MHz);

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;

  /* Configure board. Select either EBI or SPI mode. */
  BSP_Init(BSP_INIT_DK_SPI);

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  // EBI config
  EBI_Init_TypeDef ebiConfig = EBI_INIT_DEFAULT;



  // Set EBI address pins PE[15:8]
  GPIO_PinModeSet(gpioPortE, 15, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 14, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 9, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 8, gpioModePushPull, 0);

  // Set EBI data pins PA15 + PA[6:0]
  GPIO_PinModeSet(gpioPortA, 15, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 6, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 5, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 4, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 3, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 2, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0);

  /* EBI ARDY/WEN/REN/ALE */
  GPIO_PinModeSet( gpioPortF,  2, gpioModeInput,    0 );
  GPIO_PinModeSet( gpioPortF,  8, gpioModePushPull, 0 );
  GPIO_PinModeSet( gpioPortF,  9, gpioModePushPull, 0 );
  GPIO_PinModeSet( gpioPortC, 11, gpioModePushPull, 0 );

  /* --------------------------------------------------------- */
  /* Second bank needs a name, Bank 0, Base Address 0x80000000 */
  /* --------------------------------------------------------- */
      ebiConfig.banks       = EBI_BANK0;
      ebiConfig.csLines     = EBI_CS1;
      ebiConfig.mode        = ebiModeD8A8;
      ebiConfig.alePolarity = ebiActiveHigh;
      ebiConfig.location    = ebiLocation1;
      /* keep blEnable */
      ebiConfig.blEnable     = false;
      ebiConfig.addrHalfALE  = false;
      ebiConfig.readPrefetch = false;
      ebiConfig.noIdle       = true;

      /* keep alow/ahigh configuration */
      ebiConfig.aLow = ebiALowA0;
      ebiConfig.aHigh = ebiAHighA18;

      /* Address Setup and hold time */
      ebiConfig.addrHoldCycles  = 3;
      ebiConfig.addrSetupCycles = 3;

      /* Read cycle times */
      ebiConfig.readStrobeCycles = 7;
      ebiConfig.readHoldCycles   = 3;
      ebiConfig.readSetupCycles  = 3;

      /* Write cycle times */
      ebiConfig.writeStrobeCycles = 7;
      ebiConfig.writeHoldCycles   = 3;
      ebiConfig.writeSetupCycles  = 3;

      /* Configure EBI bank 1 */
      EBI_Init(&ebiConfig);


  uint16_t *BANK0_BASE_ADDR = 0x80000000;
  uint16_t DATA = 0xF000;
  uint32_t cnt = 0;
		  *BANK0_BASE_ADDR = 0x1;
		  BSP_LedsSet(0xff00);
  while (1) {
	  //if(cnt > 500000){
		  *BANK0_BASE_ADDR = DATA;
		  BSP_LedsSet(DATA);
		  Delay(500);
	  //}else{
		  *BANK0_BASE_ADDR = 0x0000;
		  BSP_LedsSet(0x0000);
	  //}
		  Delay(500);
	  //if(cnt>1000000)
	//	  cnt=0;
	  //cnt++;

  }
}
示例#13
0
void initMCU() {

	CMU_OscillatorEnable(cmuOsc_HFXO, true, true);          // enable HF XTAL osc and wait for it to stabilize
	CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);        // select HF XTAL osc as system clock source (24MHz)
	CMU_HFRCOBandSet(cmuHFRCOBand_7MHz);		//Select 7Mhz Clock
}