Exemplo n.º 1
0
void main(void)
{
  /* Turn off the watchdog timer */
  WDTCTL = WDTPW + WDTHOLD;

  /* clear reason for reset */
  SYSRSTIV = 0;
  
  /* disable DMA during read-modify-write cycles */
  DMACTL4 = DMARMWDIS;
  
  unsigned char MspVersion = GetMsp430HardwareRevision();
    
  InitializeCalibrationData();
  
  ConfigureHardware();

  OsalNvInit(0);
  
  InitializeDebugFlags();      
  InitializeButtons();
  InitializeVibration();
  InitializeOneSecondTimers();
  
  InitializeBufferPool();    

  InitializeSppTask();
  
  InitializeRealTimeClock();       

  InitializeBackgroundTask();   

  InitializeDisplayTask();   

  InitializeAdc();
  
#if 0
  /* timeout is 16 seconds */
  hal_SetWatchdogTimeout(16); 
#endif

#ifdef CHECK_FOR_PMM15
  /* make sure error pmm15 does not exist */
  while ( PMM15Check() );
#endif
  
  /* Errata PMM17 - automatic prolongation mechanism 
   * SVSLOW is disabled
   */
  *(unsigned int*)(0x0110) = 0x9602;
  *(unsigned int*)(0x0112) |= 0x0800;
  
  PrintString("Starting Task Scheduler\r\n");
  vTaskStartScheduler();

  /* if vTaskStartScheduler exits an error occured. */
  PrintString("Program Error\r\n");
  ForceWatchdogReset();
  
}
Exemplo n.º 2
0
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;
    }
}
Exemplo n.º 3
0
void main(void)
{
    ENABLE_LCD_LED();

#if ENABLE_WATCHDOG
    RestartWatchdog();
#else
    WDTCTL = WDTPW + WDTHOLD;
#endif

    /* clear shipping mode, if set to allow configuration */
    PMMCTL0_H = PMMPW_H;
    PM5CTL0 &= ~LOCKLPM5;

    /* disable DMA during read-modify-write cycles */
    DMACTL4 = DMARMWDIS;

    DetermineErrata();

#ifdef BOOTLOADER

    /*
     * enable RAM alternate interrupt vectors
     * these are defined in AltVect.s43 and copied to RAM by cstartup
     */
    SYSCTL |= SYSRIVECT;

    ClearBootloaderSignature();

#endif

    /* calibration data is used for clock setup */
    InitializeCalibrationData();

#ifndef BOOTLOADER
    SaveResetSource();
#endif

    SetupClockAndPowerManagementModule();

    OsalNvInit(0);

    /* change the mux settings according to presense of the charging clip */
    InitializeMuxMode();
    ChangeMuxMode();

    InitDebugUart();
    TestModeControl();

    /* adc is required to get the board configuration */
    InitializeAdc();
    ConfigureDefaultIO(GetBoardConfiguration());

    InitializeDebugFlags();

//  InitButton();

    InitializeVibration();
    InitializeOneSecondTimers();

    InitializeBufferPool();
    InitializeWrapperTask();
    InitializeRealTimeClock();

    InitializeDisplayTask();

    DISABLE_LCD_LED();

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

    /* Errata PMM17 - automatic prolongation mechanism
     * SVSLOW is disabled
     */
    *(unsigned int*)(0x0110) = 0x9602;
    *(unsigned int*)(0x0112) |= 0x0800;

    WhoAmI();
    PrintResetSource();

    /* if a watchdog occurred then print and save information about the source */
    WatchdogTimeoutHandler(GetResetSource());

    PrintString("Starting Task Scheduler\r\n");
    SetUartNormalMode();

    vTaskStartScheduler();

    /* if vTaskStartScheduler exits an error occured. */
    PrintString("Program Error\r\n");
    ForceWatchdogReset();
}