打印

九齐单片机

[复制链接]
541|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
cyk1|  楼主 | 2022-6-8 14:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
各位大佬,求一份九齐单片机的LVD的可用例程!

使用特权

评论回复
评论
tyw 2022-6-8 15:34 回复TA
@cyk1 :去收个中文手册 
tyw 2022-6-8 15:28 回复TA
@cyk1 :看手册设置一下的事,没人会单独写例程 
cyk1 2022-6-8 14:50 回复TA
@tyw :没有例程呀,都是些软件和PDF 
tyw 2022-6-8 14:40 回复TA
去油香收 

相关帖子

沙发
tyw| | 2022-6-8 15:22 | 只看该作者
板凳
datouyuan| | 2022-6-9 13:58 | 只看该作者
本帖最后由 tyw 于 2022-6-9 14:06 编辑
/* =========================================================================
; File:          main.asm (NY8A053E LVD function can't emulate in NY8_ICE. This function must be verification in real chip. )
; Description:   This Project teaches how to set LVD
;                1. FINST = 4MHz/4T(I_HRC)
;                2. Set LVD vlotage is 2.8V,
;                   PB0 polling with SFR bit "LVDOUT" at PCON1[6]. When VDD voltage below LVD voltage, then PB0 output low.
;                           
;                                         2.1 Using Power noise bypass capacitor between VDD and GND (0.1uF)
;                                        2.2 Set CMPCR[3:0] : 1010  
;                                        2.3 LVDS[3:0]    0000 => 1.9V
;                                                                         0001 => 2.0V
;                                                                         0010 => 2.2V
;                                                                         0011 => 2.4V
;                                                                         0100 => 2.6V                                                
;                                                                         0101 => 2.8V
;                                                                         0110 => 2.9V
;                                                                         0111 => 3.0V
;                                                                         1000 => 3.15V
;                                                                         1001 => 3.3V
;                                                                         1010 => 3.45V
;                                                                         1011 => 3.6V
;                                                                         1100 => 3.75V
;                                                                         1101 => 3.9V
;                                                                         1110 => 4.05V
;                                                                         1111 => 4.15V
;                     
; Author:        JasonLee
; Version:       V1.0
; Date:          2020/08/05
=========================================================================*/
#include <ny8.h>
#include "ny8_constant.h"

void main(void)
{
// Initial GPIO
    PORTB = 0;                                                                // PortB outputs Low
    IOSTB = 0x3E;                                                        // PB0 sets as output mode, others are input mode
    DISI();                                                                        // Disable all unmasked interrupts
    INTE = 0;                                                                // Disabl Interrupt Enable Register
    CMPCR = C_RBias_High_Dis | C_RBias_Low_Dis| C_CMPFINV_Dis | 0x0A;                // initial SFR CMPCR (CMPF_INV=0) measure LVD_L
    PCON1 = C_LVD_2P8V;                                                // Set LVDS[3:0]=0101b (2.8V) , Timer0 disable
    PCONbits.LVDEN = 1;                                                // Enable low-voltage detector               
    while(1)
    {
       if(PCON1 & 0x40)
       PORTBbits.PB0 = 1;                                        // LVDOUT -> PB0
       else
       PORTBbits.PB0 = 0;                                        // LVDOUT -> PB0
       CLRWDT();                                                        // Clear WatchDog
    }
}

/* =========================================================================
; File:          main.asm (NY8A053E LVD function can't emulate in NY8_ICE. This function must be verification in real chip. )
; Description:   This Project teaches how to set LVD
;                1. FINST = 4MHz/4T(I_HRC)
;                2. Set LVD vlotage is 2.8V,
;                   PB0 polling with SFR bit "LVDOUT" at PCON1[6]. When VDD voltage below LVD voltage, then PB0 output low.
;                           
;                                         2.1 Using Power noise bypass capacitor between VDD and GND (0.1uF)
;                                        2.2 Set CMPCR[3:0] : 1010  
;                                        2.3 LVDS[3:0]    0000 => 1.9V
;                                                                         0001 => 2.0V
;                                                                         0010 => 2.2V
;                                                                         0011 => 2.4V
;                                                                         0100 => 2.6V                                                
;                                                                         0101 => 2.8V
;                                                                         0110 => 2.9V
;                                                                         0111 => 3.0V
;                                                                         1000 => 3.15V
;                                                                         1001 => 3.3V
;                                                                         1010 => 3.45V
;                                                                         1011 => 3.6V
;                                                                         1100 => 3.75V
;                                                                         1101 => 3.9V
;                                                                         1110 => 4.05V
;                                                                         1111 => 4.15V
;                     
; Author:        JasonLee
; Version:       V1.0
; Date:          2020/08/05
=========================================================================*/
#include <ny8.h>
#include "ny8_constant.h"

void main(void)
{
// Initial GPIO
    PORTB = 0;                                                                // PortB outputs Low
    IOSTB = 0x3E;                                                        // PB0 sets as output mode, others are input mode
    DISI();                                                                        // Disable all unmasked interrupts
    INTE = 0;                                                                // Disabl Interrupt Enable Register
    CMPCR = C_RBias_High_Dis | C_RBias_Low_Dis| C_CMPFINV_Dis | 0x0A;                // initial SFR CMPCR (CMPF_INV=0) measure LVD_L
    PCON1 = C_LVD_2P8V;                                                // Set LVDS[3:0]=0101b (2.8V) , Timer0 disable
    PCONbits.LVDEN = 1;                                                // Enable low-voltage detector               
    while(1)
    {
       if(PCON1 & 0x40)
       PORTBbits.PB0 = 1;                                        // LVDOUT -> PB0
       else
       PORTBbits.PB0 = 0;                                        // LVDOUT -> PB0
       CLRWDT();                                                        // Clear WatchDog
    }
}


芯片:NY8A053E

使用特权

评论回复
地板
datouyuan| | 2022-6-9 14:02 | 只看该作者
九齐编译软件里找。

使用特权

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

本版积分规则

7

主题

18

帖子

1

粉丝