[윈도7] 환경변수 path 삭제시 복구하는 방법

공대생의 팁 2014. 9. 15. 21:41

 환경변수를 다루던 도중 실수로 전체 변수들을 덮어 씌우는 바람에 컴퓨터가 잠시 먹통이 된 적이 있습니다. 일단 환경변수가 지워져 버리면 JAVA가 실행이 되지를 않고 이것 저것 불편한게 많아져 버리기 때문에 순간 당황하시는 분들도 많으실 것이라 생각합니다.


 하지만 다시 복구할 수 있는 방법이 있으니 가슴을 다시 가다듬고 차근차근 해결해 보도록 합니다.


1. 컴퓨터에서 마우스 우측 클릭후 '속성'을 클릭합니다.



2. '고급 시스템 설정'을 클릭합니다.



3. 시스템 속성에서 '고급' 탭을 선택한 후 '환경 변수'를 클릭합니다.



4. 환경변수 창에서 시스템변수(S) 내에 Path를 더블클릭합니다.



5. 변수 값에 다음 값을 뒷부분에 추가합니다.

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;

(64비트 사용자는 위의 숫자를 64로 바꾸시면 될 듯..)



6. 시작버튼을 클릭후 CMD를 검색하여 실행합니다.




7. 명령어로 regedit를 입력후 엔터키를 누릅니다.



다음과 같으 레지스트리 편집기 창을 보실 수 있습니다.



8. 다음과 같은 폴더 경로를 따라간다.

 HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager\Enviroment\Path

해당 경로의 폴더를 열면 위의 화면과 같이 Path 폴더가 보일 것입니다. 해당 Path를 더블클릭 하면



위와 같이 삭제되기 전의 환경변수가 저장되어 있음을 확인하실 수 있습니다.

다시 5번 과정으로 돌아가 삭제되기 전의 환경변수를 입력하시면 이전의 환경변수로 다시 복원하실 수 있습니다.



참고 사이트 : http://blog.naver.com/tomato100vs1/140172845632

300x250

[Tiva] Tiva 기반 MCU로 블루투스 모듈을 활용하여 UART 통신하기

임베디드/TI 2014. 9. 13. 02:04

 MCU를 활용하여 다른 기기와의 통신으로 UART를 많이 사용할 겁니다. 이러한 MCU에 블루투스 모듈을 사용하면 간단한 설정으로 무선으로 UART를 활용할 수 있다는 점은 상당히 매력적이지요.

 다만 아쉬운 점이라면 블루투스 모듈을 사용시 AT 커맨드 등 기본적인 활용 지식이 없는 상태에서 입문하기에는 공부할 것이 많다는 점이 블루투스에 입문하는데 장벽이 되고 있기도 하지요.


 아래의 코드는 MCU와 블루투스 모듈이 연결되어 있을 때 해당 코드를 활용하면 바로 다른 기기와 연결모드에 진입할 수 있습니다. 이후 다른 기기와 블루투스를 연결하면 UART 통신을 통해 블루투스와 연결된 기기간에 통신을 할 수 있게 됩니다.


 해당 코드는 TI사의 TM4C123GH6PM MCU를 활용하였으며 소스코드는 TI사의 Tivaware 라이브러리 내의 소스코드를 활용하였습니다. 블루투스 모듈은 FirmTech 사의 FB155BC를 사용하였음을 알립니다.


※UART0은 PC와 연결되어 있으며 UART7은 블루투스 모듈과 연결되어 있습니다.

※블루투스 모듈의 모드는 AT COMMAND를 받는 모드로 설정되어 있습니다.

※블루투스 모듈에 UART로 'AT+BTSCAN'을 전송하면 블루투스 모듈이 다른 기기의 연결을 기다리게 됩니다.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/adc.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
 
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
 
void ConfigureUART(void) {
    //
    // Enable the GPIO Peripheral used by the UART.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
 
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
 
    //
    // Configure GPIO Pins for UART mode.
    //
    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    ROM_GPIOPinConfigure(GPIO_PE0_U7RX);
    ROM_GPIOPinConfigure(GPIO_PE1_U7TX);
    ROM_GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1);
 
    //
    // Use the internal 16MHz oscillator as the UART clock source.
    //
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    
    UARTClockSourceSet(UART7_BASE, UART_CLOCK_PIOSC);
 
    //
    // Initialize the UART for console I/O.
    //
    ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
            UART_CONFIG_PAR_NONE));
    ROM_UARTConfigSetExpClk(UART7_BASE, ROM_SysCtlClockGet(), 9600,
            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
            UART_CONFIG_PAR_NONE));
}
 
void findDevice() {
    UARTCharPut(UART7_BASE, 'A');
    UARTCharPut(UART7_BASE, 'T');
    UARTCharPut(UART7_BASE, '+');
    UARTCharPut(UART7_BASE, 'B');
    UARTCharPut(UART7_BASE, 'T');
    UARTCharPut(UART7_BASE, 'S');
    UARTCharPut(UART7_BASE, 'C');
    UARTCharPut(UART7_BASE, 'A');
    UARTCharPut(UART7_BASE, 'N');
    UARTCharPut(UART7_BASE, 0x0D);
}
 
void AT() {
    UARTCharPut(UART7_BASE, 'A');
    UARTCharPut(UART7_BASE, 'T');
    UARTCharPut(UART7_BASE, 0x0D);
    UARTCharPut(UART0_BASE, '0');
}
 
void UARTIntHandler() {
    unsigned char get;
    get = UARTCharGet(UART7_BASE);
    if (get == '\r') {
        UARTCharPut(UART0_BASE, '\n');
        UARTCharPut(UART0_BASE, '\r');
    } else
        UARTCharPut(UART0_BASE, get);
}
 
void InsertUART2() {
    unsigned char get;
    get = UARTCharGet(UART0_BASE);
    
    if (get == '\r') {
        UARTCharPut(UART7_BASE, '\r');
        UARTCharPut(UART7_BASE, '\n');
    } else
        UARTCharPut(UART7_BASE, get);
}
 
void SendString(char *str) {
    while (*str) {
        UARTCharPut(UART7_BASE, *str);
        SysCtlDelay(SysCtlClockGet() / 100);
        str++;
    }
    
}
 
int main(void) {
    ROM_FPULazyStackingEnable();
 
    //
    // Set the clocking to run directly from the crystal.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);
 
    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
 
    //
    // Enable the GPIO pins for the LED (PF2 & PF3).
    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
 
    //
    // Initialize the UART.
    //
    ConfigureUART();
 
    IntMasterEnable();
 
    IntEnable(79);
    UARTIntEnable(UART7_BASE, UART_INT_RX | UART_INT_RT);
    UARTIntRegister(UART7_BASE, UARTIntHandler);
 
    IntEnable(21);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    UARTIntRegister(UART0_BASE, InsertUART2);
 
    SysCtlDelay(SysCtlClockGet() / 4);
    findDevice();
 
    while (1) {
    
    UARTCharPut(UART7_BASE, 'H');
    UARTCharPut(UART7_BASE, 'e');
    UARTCharPut(UART7_BASE, 'l');
    UARTCharPut(UART7_BASE, 'l');
    UARTCharPut(UART7_BASE, 'o');
    UARTCharPut(UART7_BASE, ',');
    UARTCharPut(UART7_BASE, 'W');
    UARTCharPut(UART7_BASE, 'o');
    UARTCharPut(UART7_BASE, 'r');
    UARTCharPut(UART7_BASE, 'l');
    UARTCharPut(UART7_BASE, 'd');
    UARTCharPut(UART7_BASE, '!');
    UARTCharPut(UART7_BASE, '\n');
    UARTCharPut(UART7_BASE, '\r');
    SysCtlDelay(SysCtlClockGet());
    
    }
}
 


300x250

[Tiva] Tiva C 기반의 MCU로 초음파센서 SRF-10 활용하기

임베디드/TI 2014. 9. 12. 23:51

[SRF-10 source code using tm4c123g]


본 소스코드는 TI 사에서 제공하는 TivaWare 기반으로 작성되었으며

TI 사의 tm4c123gh6pm MCU에서 동작을 확안하였음을 알립니다.


기타 문의사항이 있으시거나 코드에 문제가 있을 경우 알려주시면 감사하겠습니다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/i2c.h"
#include "utils/uartstdio.h"
 
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
 
void ConfigureUART(void)
{
    //
    // Enable the GPIO Peripheral used by the UART.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
 
    //
    // Enable UART0
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
 
    //
    // Configure GPIO Pins for UART mode.
    //
    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
 
    //
    // Use the internal 16MHz oscillator as the UART clock source.
    //
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
 
    //
    // Initialize the UART for console I/O.
    //
    UARTStdioConfig(0, 115200, 16000000);
}
 
void DelaySoft(volatile unsigned long ulDelay) {
    SysCtlDelay((SysCtlClockGet() / 10000) * ulDelay);
}
 
#define    SLAVE_ADDRESS    0xE0 / 2
 
void ChangeAddress(int old, int new) {
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, old, false);
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x00);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0xA0);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    //SysCtlDelay(SysCtlClockGet() / 1000000 * 2);
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x00);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0xAA);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    //SysCtlDelay(SysCtlClockGet() / 1000000 * 2);
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x00);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0xA5);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    //SysCtlDelay(SysCtlClockGet() / 1000000 * 2);
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x00);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterDataPut(I2C1_BASE, new);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
}
 
int getI2CValue(int ADDR) {
    uint32_t rcv1 = 0;
    uint32_t rcv2 = 0;
    uint32_t rcv = 0;
 
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, ADDR, false);
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x00);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x51);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    SysCtlDelay(SysCtlClockGet() / 1000000 * 2);
 
    ROM_I2CMasterDataPut(I2C1_BASE, 0x02);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterDataPut(I2C1_BASE, 93);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    DelaySoft(115);
 
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, ADDR, false);
    ROM_I2CMasterDataPut(I2C1_BASE, 0x02);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, ADDR, true);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    rcv1 = ROM_I2CMasterDataGet(I2C1_BASE);
    rcv = rcv1 << 8;
 
    SysCtlDelay(SysCtlClockGet() / 1000000 * 2);
 
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, ADDR, false);
    ROM_I2CMasterDataPut(I2C1_BASE, 0x03);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, ADDR, true);
    ROM_I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    rcv2 = ROM_I2CMasterDataGet(I2C1_BASE);
    rcv += rcv2;
 
    //ROM_I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);
    //ROM_I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    //rcv = ROM_I2CMasterDataGet(I2C0_BASE);
 
    while (ROM_I2CMasterBusy(I2C1_BASE)) {
 
    }
 
    //DelaySoft(500);
    DelaySoft(300);
 
    return rcv;
}
 
int main(void) {
    //volatile uint32_t ui32Loop;
    uint32_t var1, var2;
 
    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();
 
    //
    // Set the clocking to run directly from the crystal.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
    SYSCTL_OSC_MAIN);
 
    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
 
    ROM_GPIOPinConfigure(GPIO_PA6_I2C1SCL);
    ROM_GPIOPinConfigure(GPIO_PA7_I2C1SDA);
 
    ROM_GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
    ROM_GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);
 
    ROM_I2CMasterInitExpClk(I2C1_BASE, SysCtlClockGet(), false);
 
    ROM_I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);
 
    ROM_I2CMasterEnable(I2C1_BASE);
 
 ConfigureUART();
 
 //I2C Slave의 주소를 바꿀 때 사용합니다.
 //이 때, ChangeAddress의 첫 번째 인자는 원래 주소, 두 번째 인자는 바꾸기를 원하는 주소를 입력합니다.
 //단, 첫 번째 인자의 경우 7비트로 전송해야 하므로 원래 주소 / 2 를 하여 전송하고
 //두 번째 인자의 경우 변경하기 원하는 주소를 그대로 입력해줍니다.
    //ChangeAddress(0xE0 / 2, 0xE2);
 
    //
    // We are finished.  Hang around doing nothing.
    //
    while (1) {
 
        //I2C를 통해 SRF10 초음파 거리측정 센서와 통신하여 거리를 측정합니다.
             //getI2CValue() 함수 사용시 인자는 측정을 원하는 센서의 주소를 입력합니다.
             //단, 7비트로 전송해야 하므로 원래주소 / 2 를 하여 전송합니다.
        var1 = getI2CValue(0xE0 / 2);
        var2 = getI2CValue(0xE2 / 2);
 
        UARTprintf("LEFT : %5d, RIGHT : %5d\r", var1, var2);
    }
}
 


참고 자료 : http://www.robot-electronics.co.uk/htm/srf10tech.htm

300x250