summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Basic-Test-Package/MSP432/Test_MSP432_DebugUART_EchoPC/main.c')
-rw-r--r--Basic-Test-Package/MSP432/Test_MSP432_DebugUART_EchoPC/main.c146
1 files changed, 0 insertions, 146 deletions
diff --git a/Basic-Test-Package/MSP432/Test_MSP432_DebugUART_EchoPC/main.c b/Basic-Test-Package/MSP432/Test_MSP432_DebugUART_EchoPC/main.c
deleted file mode 100644
index 8fc2001..0000000
--- a/Basic-Test-Package/MSP432/Test_MSP432_DebugUART_EchoPC/main.c
+++ /dev/null
@@ -1,146 +0,0 @@
1/******************************************************************************
2 * MSP432 UART - PC Echo with 12MHz BRCLK
3 *
4 * Description: This demo echoes back characters received via a PC serial port.
5 * SMCLK/DCO is used as a clock source and the device is put in LPM0
6 * The auto-clock enable feature is used by the eUSCI and SMCLK is turned off
7 * when the UART is idle and turned on when a receive edge is detected.
8 * Note that level shifter hardware is needed to shift between RS232 and MSP
9 * voltage levels.
10 *
11 * MSP432P401
12 * -----------------
13 * | |
14 * | |
15 * | |
16 * RST -| P1.3/UCA0TXD|----> PC (echo)
17 * | |
18 * | |
19 * | P1.2/UCA0RXD|<---- PC
20 * | |
21 *
22 * Author: Timothy Logan
23 *
24 * I3Mote Version: B.Martinez
25 *
26 *
27 *
28*******************************************************************************/
29#include "i3mote.h"
30
31/* DriverLib Includes */
32#include "driverlib.h"
33
34
35/* Standard Includes */
36#include <stdint.h>
37#include <stdbool.h>
38
39#define SYSFREQ 12000000
40
41/* UART Configuration Parameter. These are the configuration parameters to
42 * make the eUSCI A UART module to operate with a 9600 baud rate.
43 * These values were calculated using the online calculator that TI provides at:
44 * http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
45 */
46
47#ifdef UART_BAUD_9600
48 const eUSCI_UART_Config uartConfig =
49 {
50 EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
51 78, // BRDIV = 78
52 2, // UCxBRF = 2
53 0, // UCxBRS = 0
54 EUSCI_A_UART_NO_PARITY, // No Parity
55 EUSCI_A_UART_LSB_FIRST, // LSB First
56 EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
57 EUSCI_A_UART_MODE, // UART mode
58 EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
59 };
60#endif
61
62#ifdef UART_BAUD_115200
63 const eUSCI_UART_Config uartConfig =
64 {
65 EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
66 6, // BRDIV = 6
67 8, // UCxBRF = 8
68 32, // UCxBRS = 32
69 EUSCI_A_UART_NO_PARITY, // No Parity
70 EUSCI_A_UART_LSB_FIRST, // LSB First
71 EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
72 EUSCI_A_UART_MODE, // UART mode
73 EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
74 };
75#endif
76
77
78
79int main(void)
80{
81
82 /* Halting WDT */
83 MAP_WDT_A_holdTimer();
84
85 /* Selecting P1.2 and P1.3 in UART mode */
86 MAP_GPIO_setAsPeripheralModuleFunctionInputPin(UART_PORT,
87 UART_RX_PIN | UART_TX_PIN, GPIO_PRIMARY_MODULE_FUNCTION);
88
89 /* Set LEDS as output */
90 MAP_GPIO_setAsOutputPin(HID_PORT,LEDG|LEDR);
91 MAP_GPIO_setOutputLowOnPin(HID_PORT,LEDG|LEDR);
92
93 /* Setting DCO to 12MHz */
94 #if SYSFREQ==12000000
95 CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);
96 #else
97 #error "Undefinde CLock Frequency"
98 #endif
99
100 /* Configuring UART Module */
101 MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig);
102
103 /* Enable UART module */
104 MAP_UART_enableModule(EUSCI_A0_BASE);
105
106 /* Enabling UART interrupts */
107 MAP_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
108 MAP_Interrupt_enableInterrupt(INT_EUSCIA0);
109 MAP_Interrupt_enableSleepOnIsrExit();
110 MAP_Interrupt_enableMaster();
111
112 /* Enable SysTick (Toggle 0.5s) */
113 MAP_SysTick_enableModule();
114 MAP_SysTick_setPeriod(SYSFREQ/2);
115 MAP_SysTick_enableInterrupt();
116
117 /* Enabling MASTER interrupts */
118 MAP_Interrupt_enableMaster();
119
120 while(1)
121 {
122 MAP_PCM_gotoLPM0();
123 }
124}
125
126/* EUSCI A0 UART ISR - Echoes data back to PC host */
127void EUSCIA0_IRQHandler(void)
128{
129 uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_BASE);
130
131 MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status);
132
133 if(status & EUSCI_A_UART_RECEIVE_INTERRUPT)
134 {
135 MAP_UART_transmitData(EUSCI_A0_BASE, MAP_UART_receiveData(EUSCI_A0_BASE));
136 }
137
138}
139
140void SysTick_Handler(void)
141{
142 MAP_GPIO_toggleOutputOnPin(HID_PORT,LEDG);
143}
144
145
146