打印

[8/16位单片机] 【Curiosity Nano测评报告】+PIC18F47Q10测评小结

[复制链接]
2665|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 刘骁奖 于 2020-8-25 17:51 编辑

      申请了一块PIC18F47Q10-CNANO KI的评估板,Made in Malaysia,使用开发环境MPLAB X IDE V5.4 + XC8 V2.2,都是官方最新的版本。可能笔记本装的开发环境太多,把评估板接上电脑之后,一直无法找到,显示驱动问题,无耐,升级了相关开发环境,升级完成之后,记的一定要在PACKS这个页面,把开发工具相关的Device Family Packs中的升级包安装一下,包含PIC18F47Q10,ATSAMD21相关的升级包都安装一下,否则,MPLAB无法连接评估板。

资料下载地址:
                MPLAB X IDE V5.4 有win,linux,mac三种平台的版本  https://www.microchip.com/mplab/mplab-x-ide
                MPLAB® XC8 Compiler v2.20  https://www.microchip.com/mplabxc8windows
                PIC18F47Q10官方相关资料  https://www.microchip.com/wwwproducts/en/PIC18F47Q10

无法识别评估板会出如下内容:



如果不能一次连接成功,需要手动查找安装相关驱动包:



相关驱动安装完成之后,出现如下内容,设备管理器中会出现MICROCHIP TOOLS的设备,还会出现一个串口设备,电脑中显示多了一个U盘,1M大小。



新建一个工程,芯片选PIC18F47Q10,开发工具选 Curiosity Board:  PIC18F47Q10 Curiosity Nano,编译器选XC8,输入新工程的名字,工程建完之后,在source files中建一个main.c的文件就可以了。



main.c例程如下,一个让指示灯闪烁的代码,这个是用TIMER1做的定时器,参考网友代码,调试通过:
// PIC18F47Q10 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1L
#pragma config FEXTOSC = HS     // External Oscillator mode Selection bits (HS (crystal oscillator) above 8 MHz; PFM set to high power)
#pragma config RSTOSC = HFINTOSC_64MHZ// Power-up default value for COSC bits (HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1)

// CONFIG1H
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled)
#pragma config CSWEN = ON       // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)

// CONFIG2L
#pragma config MCLRE = EXTMCLR  // Master Clear Enable bit (MCLR pin (RE3) is MCLR)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (Power up timer disabled)
#pragma config LPBOREN = OFF    // Low-power BOR enable bit (Low power BOR is disabled)
#pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled , SBOREN bit is ignored)

// CONFIG2H
#pragma config BORV = VBOR_190  // Brown Out Reset Voltage selection bits (Brown-out Reset Voltage (VBOR) set to 1.90V)
#pragma config ZCD = OFF        // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
#pragma config PPS1WAY = ON     // PPSLOCK bit One-Way Set Enable bit (PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle)
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

// CONFIG3L
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = OFF        // WDT operating mode (WDT always enabled)

// CONFIG3H
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC      // WDT input clock selector (Software Control)

// CONFIG4L
#pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-003FFFh) not write-protected)
#pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (004000-007FFFh) not write-protected)
#pragma config WRT2 = OFF       // Write Protection Block 2 (Block 2 (008000-00BFFFh) not write-protected)
#pragma config WRT3 = OFF       // Write Protection Block 3 (Block 3 (00C000-00FFFFh) not write-protected)
//#pragma config WRT4 = OFF       // Write Protection Block 4 (Block 4 (010000-013FFFh) not write-protected)
//#pragma config WRT5 = OFF       // Write Protection Block 5 (Block 5 (014000-017FFFh) not write-protected)
//#pragma config WRT6 = OFF       // Write Protection Block 6 (Block 6 (018000-01BFFFh) not write-protected)
//#pragma config WRT7 = OFF       // Write Protection Block 7 (Block 7 (01C000-01FFFFh) not write-protected)

// CONFIG4H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-30000Bh) not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
#pragma config SCANE = ON       // Scanner Enable bit (Scanner module is available for use, SCANMD bit can control the module)
#pragma config LVP = ON         // Low Voltage Programming Enable bit (Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored)

// CONFIG5L
#pragma config CP = OFF         // UserNVM Program Memory Code Protection bit (UserNVM code protection disabled)
#pragma config CPD = OFF        // DataNVM Memory Code Protection bit (DataNVM code protection disabled)

// CONFIG5H

// CONFIG6L
#pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF      // Table Read Protection Block 2 (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF      // Table Read Protection Block 3 (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks)
//#pragma config EBTR4 = OFF      // Table Read Protection Block 4 (Block 4 (010000-013FFFh) not protected from table reads executed in other blocks)
//#pragma config EBTR5 = OFF      // Table Read Protection Block 5 (Block 5 (014000-017FFFh) not protected from table reads executed in other blocks)
//#pragma config EBTR6 = OFF      // Table Read Protection Block 6 (Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks)
//#pragma config EBTR7 = OFF      // Table Read Protection Block 7 (Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks)

// CONFIG6H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

#define uint unsigned int

uint num;

void timer1_init();

void main(void)
{

    timer1_init();

    ei();
    while(1){
         while(num==20)
        {

            num=0;
            PORTEbits.RE0 = 1 - PORTEbits.RE0 ;

        }
    }   
}

void timer1_init()
{
    num=0;
    TRISE=0x00;
    PORTE=0xFF;
    ANSELE = 0;

     //TMR1CLK = 0x01;
     TMR1CLK=0x04;
     OSCFRQ=0x05;
     TMR1H =(65536-500)/256;
     TMR1L = (65536-500)%256;
     T1CON = 0x03;
     //IPR4=0x04;
     PIE4bits.TMR1IE = 1;
     PIR4bits.TMR1IF = 0;
     INTCON = 0xC0;
}

void __interrupt() _timer1(void)
{
    PIR4bits.TMR1IF = 0;
    TMR1H =(65536-500)/256;
    TMR1L = (65536-500)%256;
    num++;
}









微信图片_20200825165254.png (373.99 KB )

微信图片_20200825165254.png

使用特权

评论回复
沙发
刘骁奖|  楼主 | 2020-8-25 17:57 | 只看该作者
MPLAB X IDE 使用JAVA架构,可以在MAC,WIN,LINUX上面使用,但是最大的遗憾是,在我的T440的笔记本上,运行很缓慢哦,希望MICROCHIP改进一下,优化一下编译器效率,给老工程师们,节省一点时间!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:心对了,人就对了,人对了,世界就对了! 新浪微博:http://weibo.com/mcusun

36

主题

430

帖子

22

粉丝