[PIC®/AVR®/dsPIC®产品] PIC16F17146-CNANO定时器中断应用

[复制链接]
1483|1
 楼主| gaoyang9992006 发表于 2023-7-22 19:57 | 显示全部楼层 |阅读模式
本帖最后由 gaoyang9992006 于 2023-7-23 12:57 编辑

本帖基于MPLAB X IDE V6.10版本,采用最新版MCC       Version: 5.3.7


     
  1. /*
  2. * MAIN Generated Driver File
  3. *
  4. * [url=home.php?mod=space&uid=288409]@file[/url] main.c
  5. *
  6. * @defgroup main MAIN
  7. *
  8. * [url=home.php?mod=space&uid=247401]@brief[/url] This is the generated driver implementation file for the MAIN driver.
  9. *
  10. * [url=home.php?mod=space&uid=895143]@version[/url] MAIN Driver Version 1.0.0
  11. */

  12. /*
  13. ? [2023] Microchip Technology Inc. and its subsidiaries.

  14.     Subject to your compliance with these terms, you may use Microchip
  15.     software and any derivatives exclusively with Microchip products.
  16.     You are responsible for complying with 3rd party license terms  
  17.     applicable to your use of 3rd party software (including open source  
  18.     software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
  19.     NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
  20.     SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,  
  21.     MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
  22.     WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
  23.     INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
  24.     KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
  25.     MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
  26.     FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
  27.     TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
  28.     EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
  29.     THIS SOFTWARE.
  30. */
  31. #include "mcc_generated_files/system/system.h"

  32. /*
  33.     Main application
  34. */
  35. void led(void)
  36. {
  37.     LED_Toggle();
  38. }
  39. int main(void)
  40. {
  41.     SYSTEM_Initialize();

  42.     // If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
  43.     // If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
  44.     // Use the following macros to:

  45.     // Enable the Global Interrupts
  46.     INTERRUPT_GlobalInterruptEnable();

  47.     // Disable the Global Interrupts
  48.     //INTERRUPT_GlobalInterruptDisable();

  49.     // Enable the Peripheral Interrupts
  50.     INTERRUPT_PeripheralInterruptEnable();

  51.     // Disable the Peripheral Interrupts
  52.     //INTERRUPT_PeripheralInterruptDisable();
  53.     Timer0_OverflowCallbackRegister(led);

  54.     while(1)
  55.     {
  56.     }   
  57. }



本帖子中包含更多资源

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

×

打赏榜单

zhuomuniao110 打赏了 5.00 元 2023-07-28
理由:很不错的教程,入门了。

 楼主| gaoyang9992006 发表于 2023-7-22 21:39 | 显示全部楼层
刚才有同事喊我回去吃饭,比较匆忙,不过截图已经能说明了一切,运行效果良好。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:如果你觉得我的分享或者答复还可以,请给我点赞,谢谢。

2052

主题

16403

帖子

222

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