[PIC®/AVR®/dsPIC®产品] 大家好,我想咨询一下入门PIC需要准备什么工具?

[复制链接]
29863|59
dzfansman 发表于 2021-3-9 20:44 | 显示全部楼层
PIC16F877A是典型的8位PIC单片机开发板
iamaiqiyi 发表于 2021-3-9 20:44 | 显示全部楼层
PIC18F1320单片机  
jstgotodo 发表于 2021-3-9 20:44 | 显示全部楼层
建议用MPLAB 8.86版本即可
quickman 发表于 2021-3-9 20:44 | 显示全部楼层
pic有专用的编译软件
sanfuzi 发表于 2021-3-9 20:44 | 显示全部楼层
PIC16C54推荐。
updownq 发表于 2021-3-9 20:44 | 显示全部楼层
PIC16系列单片机  
fengm 发表于 2021-3-9 20:44 | 显示全部楼层
用Proteus就可以仿真PIC单片机。
sdCAD 发表于 2021-3-9 20:44 | 显示全部楼层
较好用的是Microchip公司自己开发的集成开发环境MPLAB
wziyi 发表于 2021-3-12 12:07 | 显示全部楼层
pic kit4
 楼主| panxiaoyi 发表于 2021-3-15 17:40 | 显示全部楼层
多谢大家的解答
芯片方面选择 PIC18F27Q10  PIC18F47Q10 系列怎样?选择它们是因为它们有中文数据手册,资源丰富,某宝购买方便,也不贵,包邮10多元,是不是近几年的产品?
下载线选择 pic kit3.5 行吗?某宝查 pic kit4 好贵啊
 楼主| panxiaoyi 发表于 2021-3-15 17:41 | 显示全部楼层
PIC18F47Q10 , PIC18F27Q10

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
wziyi 发表于 2021-3-15 17:47 | 显示全部楼层
MPLAB IDE 是以前的老版本 IDE,现在官方力推的是 MPLAB X IDE 。MPLAB XC8 是编译器,需要单独安装配合 MPLAB X IDE 使用。建议买一个 MPLABPICKit4在线调试器
或者 MPLABSnap 作为编程器。
 楼主| panxiaoyi 发表于 2021-3-16 10:31 | 显示全部楼层
我现在已经安装了 MPLAB X IDE v4.20 没有安装5.x版本,因为4.x的中文界面更好
也安装了xc8
4.20新建工程时有AVR选项,但是没有芯片可供选择,请问它支持AVR吗?怎样添加芯片?如果不支持就算了,反正暂时不想用5.x
 楼主| panxiaoyi 发表于 2021-3-16 17:32 | 显示全部楼层
我用 MPLAB X IDE v4.20 新建壹个工程,使用xc8编译,用IDE的配置位生成了一段代码,然后,在网上查了壹个下午,也没有查出要插入这个main的哪一个位置
  1. /*
  2. * File:   newmain.c
  3. * Author: ADMIN
  4. *
  5. * Created on 2021年3月16日, 下午3:39
  6. */

  7. #include <stdio.h>
  8. #include <stdlib.h>

  9. /*
  10. *
  11. */
  12. int main(int argc, char** argv) {

  13.     return (EXIT_SUCCESS);
  14. }
  1. // PIC18F24Q10 Configuration Bit Settings

  2. // 'C' source line config statements

  3. // CONFIG1L
  4. #pragma config FEXTOSC = ECH    // External Oscillator mode Selection bits (EC (external clock) above 8 MHz; PFM set to high power)
  5. #pragma config RSTOSC = EXTOSC  // Power-up default value for COSC bits (EXTOSC operating per FEXTOSC bits (device manufacturing default))

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

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

  15. // CONFIG2H
  16. #pragma config BORV = VBOR_190  // Brown Out Reset Voltage selection bits (Brown-out Reset Voltage (VBOR) set to 1.90V)
  17. #pragma config ZCD = OFF        // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
  18. #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)
  19. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  20. #pragma config DEBUG = OFF      // Debugger Enable bit (Background debugger disabled)
  21. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

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

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

  28. // CONFIG4L
  29. #pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-001FFFh) not write-protected)
  30. #pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (002000-003FFFh) not write-protected)

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

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

  40. // CONFIG5H

  41. // CONFIG6L
  42. #pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-001FFFh) not protected from table reads executed in other blocks)
  43. #pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (002000-003FFFh) not protected from table reads executed in other blocks)

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

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

  48. #include <xc.h>


 楼主| panxiaoyi 发表于 2021-3-16 17:33 | 显示全部楼层
请问大家,这一窜配置位代码,要插入main的哪一个位置?多谢先
 楼主| panxiaoyi 发表于 2021-3-16 20:34 | 显示全部楼层
改成下面的样式,编译通过
  1. /*
  2. * File:   newmain.c
  3. * Author: ADMIN
  4. *
  5. * Created on 2021年3月16日, 下午8:04
  6. */

  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <xc.h>


  10. // PIC18F24Q10 Configuration Bit Settings

  11. // 'C' source line config statements

  12. // CONFIG1L
  13. #pragma config FEXTOSC = ECH    // External Oscillator mode Selection bits (EC (external clock) above 8 MHz; PFM set to high power)
  14. #pragma config RSTOSC = HFINTOSC_64MHZ// Power-up default value for COSC bits (HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1)

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

  19. // CONFIG2L
  20. #pragma config MCLRE = INTMCLR  // Master Clear Enable bit (If LVP = 0, MCLR pin (RE3) is an input; If LVP =1, MCLR pin (RE3) is MCLR)
  21. #pragma config PWRTE = OFF      // Power-up Timer Enable bit (Power up timer disabled)
  22. #pragma config LPBOREN = OFF    // Low-power BOR enable bit (Low power BOR is disabled)
  23. #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled , SBOREN bit is ignored)

  24. // CONFIG2H
  25. #pragma config BORV = VBOR_190  // Brown Out Reset Voltage selection bits (Brown-out Reset Voltage (VBOR) set to 1.90V)
  26. #pragma config ZCD = OFF        // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
  27. #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)
  28. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  29. //#pragma config DEBUG = OFF      // Debugger Enable bit (Background debugger disabled)
  30. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

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

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

  37. // CONFIG4L
  38. #pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-001FFFh) not write-protected)
  39. #pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (002000-003FFFh) not write-protected)

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

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

  49. // CONFIG5H

  50. // CONFIG6L
  51. #pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-001FFFh) not protected from table reads executed in other blocks)
  52. #pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (002000-003FFFh) not protected from table reads executed in other blocks)

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

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

  57. int main(int argc, char** argv)
  58. {
  59.     return (EXIT_SUCCESS);
  60. }
不过,下面这句也是配置字自动生成的代码,不知道为什么编译不通过?
  1. //#pragma config DEBUG = OFF      // Debugger Enable bit (Background debugger disabled)
工具也没有到货,到货就学一下
 楼主| panxiaoyi 发表于 2021-3-17 23:55 | 显示全部楼层
终于点亮了一只闪烁的LED,多谢大家的指点
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <xc.h>
  4. #include "CONFIGURATION.h"

  5. int main(int argc, char** argv)
  6. {
  7.     unsigned long i;
  8.     for(i=1000000;i>0;i--)
  9.     {
  10.         TRISA=0;
  11.         PORTA=0;
  12.     }
  13.    
  14.     for(i=1000000;i>0;i--)
  15.     {
  16.         TRISA=0;
  17.         PORTA=255;
  18.     }
  19.     return (EXIT_SUCCESS);
  20. }
  1. #ifndef XC_CONFIGURATION_H
  2. #define        XC_CONFIGURATION_H
  3. #include <xc.h> // include processor files - each processor file is guarded.  
  4. // PIC18F24Q10 Configuration Bit Settings

  5. // 'C' source line config statements

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

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

  13. // CONFIG2L
  14. #pragma config MCLRE = INTMCLR  // Master Clear Enable bit (If LVP = 0, MCLR pin (RE3) is an input; If LVP =1, MCLR pin (RE3) is MCLR)
  15. #pragma config PWRTE = OFF      // Power-up Timer Enable bit (Power up timer disabled)
  16. #pragma config LPBOREN = OFF    // Low-power BOR enable bit (Low power BOR is disabled)
  17. #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled , SBOREN bit is ignored)

  18. // CONFIG2H
  19. #pragma config BORV = VBOR_190  // Brown Out Reset Voltage selection bits (Brown-out Reset Voltage (VBOR) set to 1.90V)
  20. #pragma config ZCD = OFF        // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
  21. #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)
  22. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  23. //#pragma config DEBUG = OFF      // Debugger Enable bit (Background debugger disabled)
  24. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

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

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

  31. // CONFIG4L
  32. #pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-001FFFh) not write-protected)
  33. #pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (002000-003FFFh) not write-protected)

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

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

  43. // CONFIG5H

  44. // CONFIG6L
  45. #pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-001FFFh) not protected from table reads executed in other blocks)
  46. #pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (002000-003FFFh) not protected from table reads executed in other blocks)

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

  49. // #pragma config statements should precede project file includes.
  50. // Use project enums instead of #define for ON and OFF.
  51. #endif        /* XC_HEADER_TEMPLATE_H */


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
yzq13246068880 发表于 2021-4-8 10:40 | 显示全部楼层
非常不错
huarana 发表于 2021-4-9 08:43 | 显示全部楼层
感觉来说 业余爱好者的话 学学 arduino比较好一些,可以很方便的搭建产品 不用关心硬件底层,库比较完善。
真爱吴迪迪 发表于 2021-4-9 09:50 | 显示全部楼层
就是仿真器,其它的好像没有什么了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 在线客服 返回列表 返回顶部