int main(void)
{
    /* Halting WDT  */
    MAP_WDT_A_holdTimer();

    /* Selecting P1.2 and P1.3 in UART mode and P1.0 as output (LED) */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
             GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);

    /* Setting DCO to 48MHz (upping Vcore) */
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);

    /* Configuring UART Module */
    MAP_UART_initModule(EUSCI_A0_MODULE, &uartConfig);

    /* Enable UART module */
    MAP_UART_enableModule(EUSCI_A0_MODULE);

    /* Enabling interrupts */
    MAP_UART_enableInterrupt(EUSCI_A0_MODULE, EUSCI_A_UART_RECEIVE_INTERRUPT);
    MAP_Interrupt_enableInterrupt(INT_EUSCIA0);
    MAP_Interrupt_enableSleepOnIsrExit();

    while(1)
    {
        MAP_UART_transmitData(EUSCI_A0_MODULE, TXData);

        MAP_Interrupt_enableSleepOnIsrExit();
        MAP_PCM_gotoLPM0InterruptSafe();
    }
}
int main(void)
{
    /* Halting WDT  */
    MAP_WDT_A_holdTimer();

    /* Selecting P1.2 and P1.3 in UART mode */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
            GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);

    /* Setting DCO to 12MHz */
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);

    /* Configuring UART Module */
    MAP_UART_initModule(EUSCI_A0_MODULE, &uartConfig);

    /* Enable UART module */
    MAP_UART_enableModule(EUSCI_A0_MODULE);

    /* Enabling interrupts */
    MAP_UART_enableInterrupt(EUSCI_A0_MODULE, EUSCI_A_UART_RECEIVE_INTERRUPT);
    MAP_Interrupt_enableInterrupt(INT_EUSCIA0);
    MAP_Interrupt_enableSleepOnIsrExit();
    MAP_Interrupt_enableMaster();   

    while(1)
    {
        MAP_PCM_gotoLPM0();
    }
}
示例#3
0
void InitUart(uint32_t uartModuleBaseAdress,uint8_t uartPort,uint8_t pin1Uart,uint8_t pin2Uart,uint8_t pin3Uart,
		eUSCI_UART_Config uartConfiguration,uint8_t primaryModuleFunction)
{
	/* Selecting P1.2 and P1.3 in UART mode */
			    GPIO_setAsPeripheralModuleFunctionInputPin(uartPort,
			    		pin1Uart | pin2Uart | pin3Uart, primaryModuleFunction);
			    /* Setting DCO to 12MHz */
			    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);
			    /* Configuring UART Module */
			    UART_initModule(uartModuleBaseAdress, &uartConfiguration);
			    /* Enable UART module */
			    UART_enableModule(uartModuleBaseAdress);
}
示例#4
0
static void prvConfigureClocks( void )
{
	/* The full demo configures the clocks for maximum frequency, wheras the
	blinky demo uses a slower clock as it also uses low power features.  Maximum
	freqency also needs more voltage.

	From the datashee:  For AM_LDO_VCORE1 and AM_DCDC_VCORE1 modes, the maximum
	CPU operating frequency is 48 MHz and maximum input clock frequency for
	peripherals is 24 MHz. */
	PCM_setCoreVoltageLevel( PCM_VCORE1 );
	CS_setDCOCenteredFrequency( CS_DCO_FREQUENCY_48 );
	CS_initClockSignal( CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
	CS_initClockSignal( CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
	CS_initClockSignal( CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
	CS_initClockSignal( CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
}
示例#5
0
文件: main_blinky.c 项目: wugsh/wgs
static void prvConfigureClocks( void )
{
	/* The full demo configures the clocks for maximum frequency, wheras this
	blinky demo uses a slower clock as it also uses low power features.

	From the datasheet:  For AM_LDO_VCORE0 and AM_DCDC_VCORE0 modes, the maximum
	CPU operating frequency is 24 MHz and maximum input clock frequency for
	peripherals is 12 MHz. */
	FlashCtl_setWaitState( FLASH_BANK0, 2 );
	FlashCtl_setWaitState( FLASH_BANK1, 2 );
	CS_setDCOCenteredFrequency( CS_DCO_FREQUENCY_3 );
	CS_initClockSignal( CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
	CS_initClockSignal( CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
	CS_initClockSignal( CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
	CS_initClockSignal( CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1 );

	/* The lower frequency allows the use of CVORE level 0. */
	PCM_setCoreVoltageLevel( PCM_VCORE0 );
}
示例#6
0
void main_blinky( void )
{
	/* See http://www.FreeRTOS.org/TI_MSP432_Free_RTOS_Demo.html for 
	instructions and notes regarding the difference in power saving that can be 
	achieved between using the generic tickless RTOS implementation (as used by 
	the blinky demo) and a tickless RTOS implementation that is tailored 
	specifically to the MSP432. */

	/* The full demo configures the clocks for maximum frequency, wheras this
	blinky demo uses a slower clock as it also uses low power features. */
	prvConfigureClocks();
	CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);

	/* Create the queue. */
	xQueue = xQueueCreateStatic( mainQUEUE_LENGTH, sizeof(TransportMessages), xRxQueueBuf, &xRxQueueDef);

	if( xQueue != NULL )
	{
		/* Start the two tasks as described in the comments at the top of this
		file. */
		xTaskCreateStatic( prvQueueReceiveTask,					/* The function that implements the task. */
					"Rx", 									/* The text name assigned to the task - for debug only as it is not used by the kernel. */
					configMINIMAL_STACK_SIZE, 				/* The size of the stack to allocate to the task. */
					( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */
					mainQUEUE_RECEIVE_TASK_PRIORITY, 		/* The priority assigned to the task. */
					NULL,									/* The task handle is not required, so NULL is passed. */
					xRxStack,
					&xRxTaskBuffer);

		xTaskCreateStatic( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL,
						   xTxStack, &xTxTaskBuffer);

		/* Start the tasks and timer running. */
		vTaskStartScheduler();
	}

	/* If all is well, the scheduler will now be running, and the following
	line will never be reached.  If the following line does execute, then
	there was insufficient FreeRTOS heap memory available for the idle and/or
	timer tasks	to be created.  See the memory management section on the
	FreeRTOS web site for more details. */
	for( ;; );
}
示例#7
0
int main(void)
{
    /* Halting WDT  */
    MAP_WDT_A_holdTimer();
    
    /* Selecting P1.2 and P1.3 in UART mode */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
            GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    
    /* Setting DCO to 12MHz */
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);
    
    /* Configuring UART Module */
    MAP_UART_initModule(EUSCI_A0_MODULE, &uartConfig);
    
    /* Enable UART module */
    MAP_UART_enableModule(EUSCI_A0_MODULE);
    
    MAP_Interrupt_enableMaster();   
    
    /* Initialize values to display */
    char *s = "printf test";
    char c = '!';
    int i = -12345;
    unsigned u = 4321;
    long int l = -123456780;
    long unsigned n = 1098765432;
    unsigned x = 0xABCD;
    
    while(1)
    {
        printf(EUSCI_A0_MODULE, "String         %s\r\n", s);
        printf(EUSCI_A0_MODULE, "Char           %c\r\n", c);
        printf(EUSCI_A0_MODULE, "Integer        %i\r\n", i);
        printf(EUSCI_A0_MODULE, "Unsigned       %u\r\n", u);
        printf(EUSCI_A0_MODULE, "Long           %l\r\n", l);
        printf(EUSCI_A0_MODULE, "uNsigned loNg  %n\r\n", n);
        printf(EUSCI_A0_MODULE, "heX            %x\r\n", x);
    }
}
示例#8
0
void CS_setDCOFrequency(uint32_t dcoFrequency)
{
    int32_t nomFreq, calVal, dcoSigned;
    int16_t dcoTune;
    float dcoConst;
    bool rsel5 = false;
    dcoSigned = (int32_t) dcoFrequency;
    uint_fast8_t tlvLength;
     SysCtl_CSCalTLV_Info *csInfo;

    if (dcoFrequency < 2000000)
    {
        nomFreq = CS_15MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_1_5);
    } else if (dcoFrequency < 4000000)
    {
        nomFreq = CS_3MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_3);
    } else if (dcoFrequency < 8000000)
    {
        nomFreq = CS_6MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_6);
    } else if (dcoFrequency < 16000000)
    {
        nomFreq = CS_12MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);
    } else if (dcoFrequency < 32000000)
    {
        nomFreq = CS_24MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_24);
    } else if (dcoFrequency < 640000001)
    {
        nomFreq = CS_48MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
        rsel5 = true;
    } else
    {
        ASSERT(false);
        return;
    }
    
    /* Parsing the TLV and getting the maximum erase pulses */
    SysCtl_getTLVInfo(TLV_TAG_CS, 0, &tlvLength, (uint32_t**)&csInfo);

    if(dcoFrequency == nomFreq || tlvLength == 0)
    {
       CS_tuneDCOFrequency(0);
       return;
    }

    if ((rsel5) && ( TLV->HWREV > DEVICE_PG1_1))
    {
        /* External Resistor*/
        if (BITBAND_PERI(CS->CTL0, CS_CTL0_DCORES_OFS))
        {
            dcoConst = *((float *) &csInfo->rDCOER_CONSTK_RSEL5);
            calVal = csInfo->rDCOER_FCAL_RSEL5;
        }
        /* Internal Resistor */
        else
        {
            dcoConst = *((float *) &csInfo->rDCOIR_CONSTK_RSEL5);
            calVal = csInfo->rDCOIR_FCAL_RSEL5;
        }
    }
    /* DCORSEL = 4 */
    else
    {
        /* External Resistor */
        if (BITBAND_PERI(CS->CTL0, CS_CTL0_DCORES_OFS))
        {
            dcoConst = *((float *) &csInfo->rDCOER_CONSTK_RSEL04);
            calVal = csInfo->rDCOER_FCAL_RSEL04;
        }
        /* Internal Resistor */
        else
        {
            dcoConst = *((float *) &csInfo->rDCOIR_CONSTK_RSEL04);
            calVal = csInfo->rDCOIR_FCAL_RSEL04;
        }
    }

    if ( TLV->HWREV > DEVICE_PG1_1)
        dcoTune = (int16_t) (((dcoSigned - nomFreq)
                * (1.0f + dcoConst * (768.0f - calVal)))
                / (dcoSigned * dcoConst));
    else
        dcoTune = (int16_t) (((dcoSigned - nomFreq)
                * (1.0f + dcoConst * (768.0f - calVal)) * 8.0f)
                / (dcoSigned * dcoConst));

    CS_tuneDCOFrequency(dcoTune);

}
示例#9
0
文件: cs.c 项目: ArduCAM/Energia
void CS_setDCOFrequency(uint32_t dcoFrequency)
{
    int32_t nomFreq, calVal, dcoSigned;
    int16_t dcoTune;
    float dcoConst;
 // bool rsel5 = false;
    dcoSigned = (int32_t) dcoFrequency;

    if (dcoFrequency < 2000000)
    {
        nomFreq = CS_15MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_1_5);
    } else if (dcoFrequency < 4000000)
    {
        nomFreq = CS_3MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_3);
    } else if (dcoFrequency < 8000000)
    {
        nomFreq = CS_6MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_6);
    } else if (dcoFrequency < 16000000)
    {
        nomFreq = CS_12MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);
    } else if (dcoFrequency < 32000000)
    {
        nomFreq = CS_24MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_24);
    } else if (dcoFrequency < 640000001)
    {
        nomFreq = CS_48MHZ;
        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
      //  rsel5 = true;
    } else
    {
        ASSERT(false);
        return;
    }
    
    if(dcoFrequency == nomFreq)
    {
       CS_tuneDCOFrequency(0);
       return;
    }

    /* DCORSEL = 5, in final silicon this will have a different calibration
        value, but currently DCORSEL5 calibration is not populated 
    if (rsel5)
    {
        External Resistor 
        if (BITBAND_PERI(CS->rCTL0.r, DCORES_OFS))
        {
            dcoConst = *((float *) &TLV->rDCOER_CONSTK_RSEL5);
            calVal = TLV->rDCOER_FCAL_RSEL5;
        }
        Internal Resistor
        else
        {
            dcoConst = *((float *) &TLV->rDCOIR_CONSTK_RSEL5);
            calVal = TLV->rDCOIR_FCAL_RSEL5;
        }
    }
    DCORSEL = 4
    else
    {*/
        /* External Resistor */
        if (BITBAND_PERI(CS->rCTL0.r, DCORES_OFS))
        {
            dcoConst = *((float *) &TLV->rDCOER_CONSTK_RSEL04);
            calVal = TLV->rDCOER_FCAL_RSEL04;
        }
        /* Internal Resistor */
        else
        {
            dcoConst = *((float *) &TLV->rDCOIR_CONSTK_RSEL04);
            calVal = TLV->rDCOIR_FCAL_RSEL04;
        }
    /*}*/

    dcoTune = (int16_t) (((dcoSigned - nomFreq)
            * (1.0 + dcoConst * (768.0 - calVal)) * 8.0)
            / (dcoSigned * dcoConst));

    CS_tuneDCOFrequency(dcoTune);

}