Example #1
0
/***************************************************************************//**
 * @brief  Initializes USB clock
 * @param  none  
 * @return none 
 ******************************************************************************/
void ClockUSB(void)
{
  if (USB_PLL_XT == 2)
  {
    P5SEL |= 0x0C;                                      // Enable the XT2 pins.  Without this, the xtal pins default to being I/O's.  
        
    // Use the REFO oscillator to source the FLL and ACLK
    UCSCTL3 = (UCSCTL3 & ~(SELREF_7)) | (SELREF__REFOCLK);
    UCSCTL4 = (UCSCTL4 & ~(SELA_7)) | (SELA__REFOCLK);
        
    // MCLK will be driven by the FLL (not by XT2), referenced to the REFO
    SFRIE1 &= ~OFIE;
    Init_FLL_Settle(USB_MCLK_FREQ/1000, USB_MCLK_FREQ/32768);  // Start the FLL, at the freq indicated by the config constant USB_MCLK_FREQ
        
    XT2_Start(XT2DRIVE_0);                                        // Start the "USB crystal"
    SFRIE1 |= OFIE;
  }
  else
  {
    P5SEL |= 0x10;                                      // Enable the XT1 pins.  Without this, the xtal pins default to being I/O's.  
        
    // Use the REFO oscillator to source the FLL and ACLK
    UCSCTL3 = SELREF__REFOCLK;             
    UCSCTL4 = (UCSCTL4 & ~(SELA_7)) | (SELA__REFOCLK); 
        
    SFRIE1 &= ~OFIE;
    // MCLK will be driven by the FLL (not by XT2), referenced to the REFO
    Init_FLL_Settle(USB_MCLK_FREQ/1000, USB_MCLK_FREQ/32768); // set FLL (DCOCLK)
        
    XT1_Start(XT1DRIVE_0);                                       // Start the "USB crystal"
    SFRIE1 |= OFIE;
  }
}
Example #2
0
/*  
 * ======== Init_Clock ========
 */
VOID Init_Clock (VOID)
{
    //Initialization of clock module
    if (USB_PLL_XT == 2){
		#if defined (__MSP430F552x) || defined (__MSP430F550x)
			P5SEL |= 0x0C;                                      //enable XT2 pins for F5529
		#elif defined (__MSP430F563x_F663x)
			P7SEL |= 0x0C;
		#endif

        //use REFO for FLL and ACLK
        UCSCTL3 = (UCSCTL3 & ~(SELREF_7)) | (SELREF__REFOCLK);
        UCSCTL4 = (UCSCTL4 & ~(SELA_7)) | (SELA__REFOCLK);

        //MCLK will be driven by the FLL (not by XT2), referenced to the REFO
        Init_FLL_Settle(USB_MCLK_FREQ / 1000, USB_MCLK_FREQ / 32768);   //Start the FLL, at the freq indicated by the config
                                                                        //constant USB_MCLK_FREQ
        XT2_Start(XT2DRIVE_0);                                          //Start the "USB crystal"
    } 
	else {
		#if defined (__MSP430F552x) || defined (__MSP430F550x)
			P5SEL |= 0x10;                                      //enable XT1 pins
		#endif
        //Use the REFO oscillator to source the FLL and ACLK
        UCSCTL3 = SELREF__REFOCLK;
        UCSCTL4 = (UCSCTL4 & ~(SELA_7)) | (SELA__REFOCLK);

        //MCLK will be driven by the FLL (not by XT2), referenced to the REFO
        Init_FLL_Settle(USB_MCLK_FREQ / 1000, USB_MCLK_FREQ / 32768);   //set FLL (DCOCLK)

        XT1_Start(XT1DRIVE_0);                                          //Start the "USB crystal"
    }
}
Example #3
0
static void prvSetupHardware( void )
{
    /* Convert a Hz value to a KHz value, as required by the Init_FLL_Settle()
    function. */
    unsigned long ulCPU_Clock_KHz = ( configCPU_CLOCK_HZ / 1000UL );

    halBoardInit();

    LFXT_Start( XT1DRIVE_0 );
    Init_FLL_Settle( ( unsigned short ) ulCPU_Clock_KHz, 488 );

    halButtonsInit( BUTTON_ALL );
    halButtonsInterruptEnable( BUTTON_SELECT );

    /* Initialise the LCD, but note that the backlight is not used as the
    library function uses timer A0 to modulate the backlight, and this file
    defines	vApplicationSetupTimerInterrupt() to also use timer A0 to generate
    the tick interrupt.  If the backlight is required, then change either the
    halLCD library or vApplicationSetupTimerInterrupt() to use a different
    timer.  Timer A1 is used for the run time stats time base6. */
    halLcdInit();
    halLcdSetContrast( 100 );
    halLcdClearScreen();

    halLcdPrintLine( " www.FreeRTOS.org", 0,  OVERWRITE_TEXT );
}
/**********************************************************************//**
 * @brief  Set function for MCLK frequency.
 *
 *
 * @return none
 *************************************************************************/
void hal430SetSystemClock(unsigned long req_clock_rate, unsigned long ref_clock_rate)
{
  /* Convert a Hz value to a KHz value, as required
   *  by the Init_FLL_Settle() function. */
  unsigned long ulCPU_Clock_KHz = req_clock_rate / 1000UL;

  //Make sure we aren't overclocking
  if(ulCPU_Clock_KHz > 25000L)
  {
    ulCPU_Clock_KHz = 25000L;
  }

  //Set VCore to a level sufficient for the requested clock speed.
  if(ulCPU_Clock_KHz <= 8000L)
  {
    SetVCore(PMMCOREV_0);
  }
  else if(ulCPU_Clock_KHz <= 12000L)
  {
    SetVCore(PMMCOREV_1);
  }
  else if(ulCPU_Clock_KHz <= 20000L)
  {
    SetVCore(PMMCOREV_2);
  }
  else
  {
    SetVCore(PMMCOREV_3);
  }

  //Set the DCO
  Init_FLL_Settle( ( unsigned short )ulCPU_Clock_KHz, req_clock_rate / ref_clock_rate );
}
void SetupClockAndPowerManagementModule(void)
{
    // see Frequency vs Supply Voltage in MSP4305438A data sheet
    SetVCore(PMMCOREV_2);

    // setup pins for XT1
    P7SEL |= BIT0 + BIT1;

    // Startup LFXT1 32 kHz crystal
    while (LFXT_Start_Timeout(XT1DRIVE_0, 50000) == UCS_STATUS_ERROR);

    // select the sources for the FLL reference and ACLK
    SELECT_ACLK(SELA__XT1CLK);
    SELECT_FLLREF(SELREF__XT1CLK);

    // 512 * 32768 = 16777216 / 1024
    Init_FLL_Settle(configCPU_CLOCK_HZ/configTICK_RATE_HZ, ACLK_MULTIPLIER);

    // Disable FLL loop control
    __bis_SR_register(SCG0);

    // setup for quick wake up from interrupt and
    // minimal power consumption in sleep mode
    DISABLE_SVSL();                           // SVS Low side is turned off
    DISABLE_SVSL_RESET();

    DISABLE_SVML();                           // Monitor low side is turned off
    DISABLE_SVML_INTERRUPT();

    DISABLE_SVMH();                           // Monitor high side is turned off
    DISABLE_SVMH_INTERRUPT();

    ENABLE_SVSH();                            // SVS High side is turned on
    ENABLE_SVSH_RESET();                      // Enable POR on SVS Event

    SVSH_ENABLED_IN_LPM_FULL_PERF();          // SVS high side Full perf mode,
    // stays on in LPM3,enhanced protect

    // Wait until high side, low side settled
    while ((PMMIFG & SVSMLDLYIFG) == 0 && (PMMIFG & SVSMHDLYIFG) == 0);
    CLEAR_PMM_IFGS();

#if CHECK_FOR_PMM15
    /* make sure error pmm15 does not exist */
    while (PMM15Check());
#endif

    if (Errata())
    {
        /* Errata PMM17 - automatic prolongation mechanism
        * SVSLOW is disabled
        */
        *(unsigned int*)(0x0110) = 0x9602;
        *(unsigned int*)(0x0112) |= 0x0800;
    }
}
Example #6
0
//*****************************************************************************
//
//! initClk
//!
//!  @param  None
//!
//!  @return none
//!
//!  @brief  Init the device with 16 MHz DCOCLCK.
//
//*****************************************************************************
void initClk(void)
{	
	// Set Vcore to accomodate for max. allowed system speed
	SetVCore(3);
	// Use 32.768kHz XTAL as reference
	LFXT_Start(XT1DRIVE_0);
	
	// Set system clock to max (25MHz)
	Init_FLL_Settle(25000, 762);
	SFRIFG1 = 0;
	SFRIE1 |= OFIE;
}
Example #7
0
void SysInit(void)
{
    WDTCTL = WDTPW | WDTHOLD;	  // Stop watchdog timer
	Board_init();                 // Basic GPIO initialization
	SetVCore(3);                  // Set Vcore to accomodate for max. allowed system speed
	LFXT_Start(XT1DRIVE_0);       // Use 32.768kHz XTAL as reference, ACLK: SELA = 000, DIVA = 000
	Init_FLL_Settle(25000, 762);  // Set system clock to max (25MHz)

    LcdInit();
    LcdClear();
    //display_rect();
    AD9954Init();

    P4SEL = 0x00;
    P4DIR = 0x00;
    P4REN = 0xff;
}
Example #8
0
static void prvSetupHardware(void) {
    /* Convert a Hz value to a KHz value, as required by the Init_FLL_Settle()
     function. */
    unsigned long ulCPU_Clock_KHz = (25000000UL / 1000UL );

    /* Disable the watchdog. */
    WDTCTL = WDTPW + 0x36;
    SFRIE1 |= WDTIE;

    /* select port pin functions */
    halBoardInit();

    LFXT_Start(XT1DRIVE_0); 								/* enable oszillator */
    Init_FLL_Settle((unsigned short) ulCPU_Clock_KHz, 488);	/* clock divisor */


}
Example #9
0
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
    taskDISABLE_INTERRUPTS();

    /* Disable the watchdog. */
    WDTCTL = WDTPW + WDTHOLD;

    //halBoardInit();
    Board_init();

    // Set Vcore to accomodate for max. allowed system speed
    SetVCore(3);

    // Use 32.768kHz XTAL as reference
    LFXT_Start(XT1DRIVE_0);

    // Set system clock to max (25MHz)
    Init_FLL_Settle(25000, 762);

    SFRIFG1 = 0;
    SFRIE1 |= OFIE;

    //LFXT_Start( XT1DRIVE_0 );
    //hal430SetSystemClock( configCPU_CLOCK_HZ, configLFXT_CLOCK_HZ );

    //halButtonsInit( BUTTON_ALL );
    Buttons_init(BUTTON_ALL);
    //halButtonsInterruptEnable( BUTTON_SELECT );
    Buttons_interruptEnable(BUTTON_S2);

    /* Initialise the LCD, but note that the backlight is not used as the
    library function uses timer A0 to modulate the backlight, and this file
    defines	vApplicationSetupTimerInterrupt() to also use timer A0 to generate
    the tick interrupt.  If the backlight is required, then change either the
    halLCD library or vApplicationSetupTimerInterrupt() to use a different
    timer.  Timer A1 is used for the run time stats time base6. */
    //halLcdInit();
    //halLcdSetContrast( 100 );
    //halLcdClearScreen();

    //halLcdPrintLine( " www.FreeRTOS.org", 0,  OVERWRITE_TEXT );
}
Example #10
0
void MassStorage(void)
{
    buttonsPressed = 0;

    SFRIE1 &= ~OFIE;
    disk_initialize(0);                   // Initialize Disk Drive #0

    SFRIE1 |= OFIE;

    DEBUG("Init clock\r\n");
    ClockUSB();

    DEBUG("Init USB\r\n");
    USB_init();                           // Initialize the USB module
    P1OUT |= BIT1;

    // Enable all USB events
    USB_setEnabledEvents(kUSB_allUsbEvents);

    // Clal Initialization Function
    DEBUG("Init MSC\r\n");
    msc_Init();
    P1OUT |= BIT2;

    // If USB is already connected when the program starts up, then there won't be a
    // USB_handleVbusOnEvent().
    // So we need to check for it, and manually connect if the host is already present.
    if (USB_connectionInfo() & kUSB_vbusPresent)
    {
        if (USB_enable() == kUSB_succeed)
        {
            USB_reset();
            USB_connect();
            P1OUT |= BIT3;
        }
    }

    while (1)
    {
        switch (USB_connectionState())
        {
            DEBUG("Connection state: %u\r\n", USB_connectionState());
            case ST_USB_DISCONNECTED:
                //__bis_SR_register(LPM3_bits + GIE);    // Enter LPM3 until VBUS-on event
                _NOP();
                break;

            case ST_USB_CONNECTED_NO_ENUM:
                break;

            case ST_ENUM_ACTIVE:

                msc_Loop();
                break;

            case ST_ENUM_SUSPENDED:
                //__bis_SR_register(LPM3_bits + GIE);    // Enter LPM3, until a resume or VBUS-off
                                                       // event
                break;

            case ST_ENUM_IN_PROGRESS:
                break;

            case ST_ERROR:
                break;
            default:;
        }
    }

    DEBUG("Done with MassStorage\r\n");
    buttonsPressed = 0;
    Board_ledOff(LED_ALL);
    USB_disable();
    SFRIE1 &= ~OFIE;
    Init_FLL_Settle(25000, 762);          // Return to normal clock settings
    SFRIE1 |= OFIE;
}