Step by Step to Program PIC18F452 Using ICD3
Total Page:16
File Type:pdf, Size:1020Kb
Step by Step to Program PIC18F452 Using ICD3
MPLAB Driver Switcher
1. You will be using the MPLAB ICD3 to re-program Qwikbug onto the Qwikflash board (picboard).
2. Plug in ICD 3 to the top left front USBport and the RJ11 (short jumper cable) into the top left of the Qwikflash board (DO NOT turn it on)
3. Open MPLAB driver switcher
4. Highlight ICD 3 AND select Group Driver Selection to be Applied: MPLAB8
5. Select apply changes and wait until the message Apply Changes Done is displayed at the bottom of the main window.
6. Unplug the ICD 3 MPLAB IDE 8.3
7. Make sure MPLAB IDE version is v8.30 and above.
8. Disconnect the Serial Cable (DB9/tan cable) from the Qwikflash board
9. Download
10. Open MPLAB IDE v8.30 and expand so it fits the screen
11. Create a new project using Project Wizard (Project -> Project Wizard)
10.1 From Welcome page, select Next>
10.2 In Step One window, make sure in the Device window, select PIC18F452, then select Next> 10.3 In Step Two window, select SASM in Active Toolsuite. In Toolsuite Contents window, SASM and MPLINK should be shown up. Move mouse to highlight SASM, check the Location window, use Browse to select sasm.exe file; then highlight the MPLINK, use Browse to select mplink.exe file. Then press Next> 10.4 In Step Three window, use Browse to select the path and give the name of new Project File, then press Next> 10.5 In Step Four window, leave it blank, press Next> 10.6 In Summary window, check the information are correct, then press Finish button. 11 Then get the following window. Use mouse to select the Source Files folder in .mcw window. Right clock the mouse to pull down a menu, then select
12 It will open an Add Files to Project window, as below. Select the QB124.asm, then open the file. 13 You will get the following window 14. Build your project (Project -> Build). You should see the follow results.
15. Click OK of the pop up window. You will get the following output:
16. On the toolbar, got to Programemer > Select Programmer> MPLAB ICD 3
17. Plug the ICD 3 into the top left USB port
18. You get the following window 19. Flip the swtich to turn on the Quickflash board. You will get a Voltage caution window as below. Press OK button to close the pop-up window. 20. You should get the following message in Output window:
Target Detected
Device ID Revision = xxxxxxxxx
21. Go to Configuration Bits window to modify configuration bits (Configure > Configuration Bit…). Uncheck the box: Configuration Bits set in code. Expand each column if need be to see more clearly. Window will pop up, Press ok 22. Then make sure the following configuration is as follows:
Oscillator HS
Osc. Switch Enable Enable
Power Up Timer Enable
Brown Out Detect Enable
Brown Out Voltage 4.5V
Watchdog Timer Disabled- Controlled by SWDTEN bit
Watchdog Postscaler 1:128
CCP2 MUX RC1
Stack Overflow Reset Enable
Low Voltage Program Disabled
Code Protect 06000-07fff Enable
All others configuration bits should be as Disabled as indicate in the following window: 23. Go to ICD settings window by Programmer > Settings…
24. Select: Manually select memories and ranges, check program, configuration, EEPROM, and ID under memories and make program memory range from 0 to 7fff. Check erase all before program under program options and program after successful build under automatically 25. Erase the device by selecting Programmer > Erase Flash Device
26. Select Programmer > Program. It will take about 1 minute to complete the programing
27. You should get the following message from the Output window:
Programming …
Programming/Verify complete 28. Select Programmer > Reconnect. Press ok when voltage caution window pops up
29. Select Debugger > Select Tool > MPLAB ICD 3 as in the following window.
30. If this window pops up press ok and ok when the voltage caution window pops up The program may freeze for a second at this point. It is ok.
31. You will then get this screen, move the QB124.APR window out of the way (do not minimize it will pop back up) 32. Then run the debugger by Debugger > Run, then press YES on the pop up Target Out Of Date window.
33. You will then get the following screen: 34. Make sure under configure>configure bits, code protect 06000-07FFF is still enabled.
35. Select Debugger>Program and you will get the following pop up window
36. Press OK and wait until programming is complete 37. Run the debugger again by selecting Debugger>Run
38. After a few seconds, you should get an error message “Failed to get PC” in the output window as below Once the error message is printed, disconnect the RJ11 cable from the Qwikflash board and connect the serial cable (DB9 connector). Open tera term pro and press enter a few times. You should get the following window: While still in tera term pro, turn off the qwikflash board and turn it back on. You will get the following window and qwikbug has been installed
39. If after a few seconds you do not get the error message as above, but the debugger continues to run, move your mouse to the upper right hand corner of MPLAB IDE 8.3 and press the halt (pause) button wait for “The failed to get PC” error message as above and continue as in step 38.