申请的PIC24F16KL402 开发板使用笔记一: 搭建基本开发环境
开发板类型: Microchiop用于3v PIC24 K系列的Micros tick开发板
Author: ARIC
年终奖时中了ipad结果提前走了没拿到,没想到可以申请到开发板, 心喜若狂啊!从没在本站发过帖子,处女秀。主要是本人水平有限难登大雅之堂。
本人之前从未使用过PIC24XXX的MCU, 刚拿到从网上看了一翻资料,发现上手快没那么简单啊。继续努力中...
本人真心的喜欢这个芯片的,外设丰富。第一天吧,把开发环境搭起来吧。准备一下开发工具,下载MPLAP X IDE.
Duang duang duang!!!
下载并安装完成, 第一步done.
Step 1: 启动开发工具,非常友好的开发界面。
Step 2:使用向导新建一个模板。
Step 3:第一个Helloworld的程序
点亮这个LED0
Code:
- #include
- // Configuration Bits to make the part run from Internal FRCDIV
- // Oscillator.
- _FBS
- (
- BWRP_OFF & // Boot Segment Write Protect (Disabled)
- BSS_OFF // Boot segment Protect (No boot flash segment)
- )
- _FGS
- (
- GWRP_OFF & // General Segment Flash Write Protect (General segment may be written)
- GSS0_OFF // General Segment Code Protect (No Protection)
- )
- _FOSCSEL
- (
- FNOSC_FRCDIV & // Oscillator Select (8MHz FRC with Postscaler (FRCDIV))
- SOSCSRC_ANA & // SOSC Source Type (Analog Mode for use with crystal)
- LPRCSEL_HP & // LPRC Power and Accuracy (High Power/High Accuracy)
- IESO_ON // Internal External Switch Over bit (Internal External Switchover mode enabled (Two-speed Start-up enabled))
- )
- _FOSC
- (
- POSCMD_NONE & // Primary Oscillator Mode (Primary oscillator disabled)
- OSCIOFNC_ON & // CLKO Enable Configuration bit (CLKO output signal enabled)
- POSCFREQ_MS & // Primary Oscillator Frequency Range Configuration bits (Primary oscillator/external clock frequency between 100kHz to 8MHz)
- SOSCSEL_SOSCHP &// SOSC Power Selection Configuration bits (Secondary Oscillator configured for high-power operation)
- FCKSM_CSECME // Clock Switching and Monitor Selection (Clock Switching and Fail-safe Clock Monitor Enabled)
- )
- _FWDT
- (
- WDTPS_PS32768 & // Watchdog Timer Postscale Select bits (1:32768)
- FWPSA_PR128 & // WDT Prescaler bit (WDT prescaler ratio of 1:128)
- FWDTEN_OFF & // Watchdog Timer Enable bits (WDT disabled in hardware; SWDTEN bit disabled)
- WINDIS_OFF // Windowed Watchdog Timer Disable bit (Standard WDT selected (windowed WDT disabled))
- )
- // Warning:
- // Always enable MCLRE_ON config bit setting so that the MCLR pin function will
- // work for low-voltage In-Circuit Serial Programming (ICSP). The Microstick
- // programming circuitry only supports low-voltage ICSP. If you disable MCLR pin
- // functionality, a high-voltage ICSP tool will be required to re-program the
- // part in the future.
- _FPOR
- (
- BOREN_BOR3 & // Brown-out Reset Enable bits (Enabled in hardware; SBOREN bit disabled)
- PWRTEN_ON & // Power-up Timer Enable (PWRT enabled)
- I2C1SEL_PRI & // Alternate I2C1 Pin Mapping bit (Default SCL1/SDA1 Pins for I2C1)
- BORV_V18 & // Brown-out Reset Voltage bits (Brown-out Reset at 1.8V)
- MCLRE_ON // MCLR Pin Enable bit (RA5 input disabled; MCLR enabled)
- )
- _FICD
- (
- ICS_PGx3 // ICD Pin Placement Select (EMUC/EMUD share PGC3/PGD3)
- )
- void DelaymS(unsigned int del)
- {
- unsigned int j;
- while(del--)
- for(j=0;j<1600;j++);
- }
- int main(void)
- {
- unsigned int i;
- // Set up output pin for LED
- TRISAbits.TRISA0 = 0;
- while(1)
- {
- // (insert your application code here)
- DelaymS(500);
- // Toggle the LED output pin to alternate between the LED being on and off
- LATAbits.LATA0 ^= 1;
- }
- }
- Step 4:编译链接并下载
- 插上开发板,点击"运行项目“,就可以看到LED开始blink.
复制代码
0
|
|
|
|
朋友我是Proteus板块的版主,欢迎你!我的qq是441747863,真心希望一起出贴子,一起研究。
|
|
|
|
|