/**
TMR0 Generated Driver File
@Company
Microchip Technology Inc.
@File Name
tmr0.c
@Summary
This is the generated driver implementation file for the TMR0 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
@Description
This source file provides APIs for TMR0.
Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
Device : PIC16F753
Driver Version : 2.01
The generated drivers are tested against the following:
Compiler : XC8 1.45
MPLAB : MPLAB X 4.15
*/
/*
(c) 2018 Microchip Technology Inc. and its subsidiaries.
Subject to your compliance with these terms, you may use Microchip software and any
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
license terms applicable to your use of third party software (including open source software) that
may accompany Microchip software.
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
FOR A PARTICULAR PURPOSE.
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
SOFTWARE.
*/
/**
Section: Included Files
*/
#include <xc.h>
#include "tmr0.h"
/**
Section: Global Variables Definitions
*/
volatile uint8_t timer0ReloadVal;
void (*TMR0_InterruptHandler)(void);
/**
Section: TMR0 APIs
*/
void TMR0_Initialize(void)
{
// Set TMR0 to the options selected in the User Interface
// PSA not_assigned; PS 1:256; TMRSE Increment_hi_lo; mask the nWPUEN and INTEDG bits
OPTION_REG = (uint8_t)((OPTION_REG & 0xC0) | (0xFF & 0x3F));
// TMR0 156;
TMR0 = 0x9C;
// Load the TMR value to reload variable
timer0ReloadVal= 156;
// Clear Interrupt flag before enabling the interrupt
INTCONbits.T0IF = 0;
// Enabling TMR0 interrupt
INTCONbits.T0IE = 1;
// Set Default Interrupt Handler
TMR0_SetInterruptHandler(TMR0_DefaultInterruptHandler);
}
uint8_t TMR0_ReadTimer(void)
{
uint8_t readVal;
readVal = TMR0;
return readVal;
}
void TMR0_WriteTimer(uint8_t timerVal)
{
// Write to the Timer0 register
TMR0 = timerVal;
}
void TMR0_Reload(void)
{
// Write to the Timer0 register
TMR0 = timer0ReloadVal;
}
void TMR0_ISR(void)
{
// Clear the TMR0 interrupt flag
INTCONbits.T0IF = 0;
TMR0 = timer0ReloadVal;
if(TMR0_InterruptHandler)
{
TMR0_InterruptHandler();
}
// add your TMR0 interrupt custom code
}
void TMR0_SetInterruptHandler(void (* InterruptHandler)(void)){
TMR0_InterruptHandler = InterruptHandler;
}
void TMR0_DefaultInterruptHandler(void){
// add your TMR0 interrupt custom code
// or set custom function using TMR0_SetInterruptHandler()
}
/**
End of File
*/
PIC16F753.X.zip_PIC16F753_stepa4t_universeg8x
版权申诉
186 浏览量
2022-07-14
05:36:02
上传
评论
收藏 107KB ZIP 举报
林当时
- 粉丝: 100
- 资源: 1万+
最新资源
- 微信小程序 - 图书管理系统源码.zip
- 微信小程序 - 图片自适应 ,富文本解析源码.zip
- 微信小程序 - 同乐居商城:购物车合算源码
- 1、根据输入的三条边值判断能组成何种三角形,并设计测试数据进行判定覆盖测试 三条边为变量a、b、c,范围为1≤边值≤10,不在范
- SQL server 练习题目8道(小白教学).zip
- Python 手写实现 iD3 决策树算法-根据信息增益公式.zip
- 411675952289057车联助手-小窗版(三星)3.5.1.apk
- 三种快速排序方法合并在一个文件中以便直接运行的Python代码示例
- 937712277954201实习5.word
- 2程序语言基础知识pdf1_1716337722703.jpeg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈