否則X IDE可能會(huì)提示以下錯(cuò)誤:
Target device was not found (could not detect target voltage VDD). You must connect to a target device to use PICkit 3.
7, 執(zhí)行mcc。
1) 在Pin Manager中,設(shè)置RD0和RB5為output。
2) 點(diǎn)擊Generate按鈕生成.c和.h文件,復(fù)制C:\Users\junha\.mcc目錄下的文件到步驟4中項(xiàng)目的目錄下,初始化入口system.c/SYSTEM_Initialize(),確保PIN_MANAGER_Initialize IO初始化正確。
TRISB = 0xFBDB;
TRISD = 0xFFFE;
8, 修改main.c,設(shè)置RED/GRN LED輸出。
void delay(int len)
{
int i = 0;
int d = 100;
i = d * len;
while(--i)
{
}
}
int main(void)
{
// initialize the device
SYSTEM_Initialize();
while (1)
{
// Add your application code
PORTB |= (1 << 5); //滅燈
PORTD &= ~(1 << 0); //點(diǎn)亮
delay(100000);
PORTB &= ~(1 << 5); //點(diǎn)亮
PORTD |= (1 << 0); //滅燈
delay(100000);
}
return 1;
}
9, 編譯:Production -> Build Main Project
10, 軟件仿真。
1) Debug Tool確保選擇Simulator。選擇這個(gè)模式后,燒錄按鈕灰掉了,不能燒錄。
2) 執(zhí)行Debug -> Debug Main Project,通過(guò)設(shè)置斷點(diǎn),watch對(duì)應(yīng)的寄存器來(lái)調(diào)試。
11, 燒錄調(diào)試
執(zhí)行Make and Program Device Main Project. 日志如下:
****************************************************
Connecting to MPLAB PICkit 3...
Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.54.00
Firmware type..............dsPIC33E/24E
Target voltage detected
Target device dsPIC33EP128GS706 found.
Device Revision ID = 4002
DEVSN0 = 00000000
DEVSN1 = 00000000
Device Erased...
Programming...
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x7ff
Programming/Verify complete
12, 板子自動(dòng)運(yùn)行燒錄程序,分別點(diǎn)亮RED/GRN LED。