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();
    }
}
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();
    }
}
Esempio n. 3
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);
    }
}
Esempio n. 4
0
/*
 * See the serial2.h header file.
 */
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned long uxQueueLength )
{
	/* Create the queue used to hold received characters.  NOTE THE COMMENTS AT
	THE TOP OF THIS FILE REGARDING THE USE OF QUEUES FOR THIS PURPSOE. */
	xRxQueue = xQueueCreate( uxQueueLength, sizeof( char ) );
	configASSERT( xRxQueue );

	/* Use the library functions to initialise and enable the UART. */
	MAP_UART_initModule( EUSCI_A0_MODULE, &xUARTConfig );
	MAP_UART_enableModule( EUSCI_A0_MODULE );
	MAP_UART_clearInterruptFlag( EUSCI_A0_MODULE, EUSCI_A_UART_RECEIVE_INTERRUPT | EUSCI_A_UART_TRANSMIT_INTERRUPT );
	MAP_UART_enableInterrupt( EUSCI_A0_MODULE, EUSCI_A_UART_RECEIVE_INTERRUPT );

	/* The interrupt handler uses the FreeRTOS API function so its priority must
	be at or below the configured maximum system call interrupt priority.
	configKERNEL_INTERRUPT_PRIORITY is the priority used by the RTOS tick and
	(should) always be set to the minimum priority. */
	MAP_Interrupt_setPriority( INT_EUSCIA0, configKERNEL_INTERRUPT_PRIORITY );
	MAP_Interrupt_enableInterrupt( INT_EUSCIA0 );

	/* Only one UART is supported so the handle is not used. */
	return ( xComPortHandle ) 0;
}
/*
 *  ======== initHW ========
 *
 *  Configures UART peripheral
 */
static void initHw(UARTMSP432_Object *object,
    UARTMSP432_HWAttrs const *hwAttrs, uint32_t inputClkFreq)
{
    int32_t           baudrateIndex;
    eUSCI_UART_Config uartConfig;

    /*
     * This will never return -1, constarints prevent unsupported performance
     * levels
     */
    baudrateIndex = findBaudDividerIndex(hwAttrs->baudrateLUT,
        hwAttrs->numBaudrateEntries, object->baudRate, inputClkFreq);

    uartConfig.selectClockSource = hwAttrs->clockSource;
    uartConfig.clockPrescalar = hwAttrs->baudrateLUT[baudrateIndex].prescalar;
    uartConfig.firstModReg = hwAttrs->baudrateLUT[baudrateIndex].hwRegUCBRFx;
    uartConfig.secondModReg = hwAttrs->baudrateLUT[baudrateIndex].hwRegUCBRSx;
    uartConfig.parity = parityTypes[object->parityType];
    uartConfig.msborLsbFirst = hwAttrs->bitOrder;
    uartConfig.numberofStopBits = stopBits[object->stopBits];
    uartConfig.uartMode = EUSCI_A_UART_MODE;
    uartConfig.overSampling = hwAttrs->baudrateLUT[baudrateIndex].sampling;

    MAP_UART_initModule(hwAttrs->baseAddr, &uartConfig);

    /* Enable UART and disable its interrupts. */
    MAP_UART_enableInterrupt(hwAttrs->baseAddr,
        EUSCI_A_UART_BREAKCHAR_INTERRUPT |
        EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT);
    MAP_UART_disableInterrupt(hwAttrs->baseAddr, EUSCI_A_UART_TRANSMIT_INTERRUPT);

    MAP_UART_enableModule(hwAttrs->baseAddr);
    MAP_UART_enableInterrupt(hwAttrs->baseAddr, EUSCI_A_UART_RECEIVE_INTERRUPT);

    DebugP_log3("UART:(%p) CPU freq: %d; UART baudRate to %d", hwAttrs->baseAddr,
        inputClkFreq, object->baudRate);
}