九齐单片机

[复制链接]
 楼主| cyk1 发表于 2022-6-8 14:37 | 显示全部楼层 |阅读模式
各位大佬,求一份九齐单片机的LVD的可用例程!

评论

tyw
[url=home.php?mod=space&uid=3344818]@cyk1[/url] :去收个中文手册  发表于 2022-6-8 15:34
tyw
[url=home.php?mod=space&uid=3344818]@cyk1[/url] :看手册设置一下的事,没人会单独写例程  发表于 2022-6-8 15:28
[url=home.php?mod=space&uid=7589]@tyw[/url] :没有例程呀,都是些软件和PDF  发表于 2022-6-8 14:50
tyw
去油香收  发表于 2022-6-8 14:40
tyw 发表于 2022-6-8 15:22 | 显示全部楼层
datouyuan 发表于 2022-6-9 13:58 | 显示全部楼层
本帖最后由 tyw 于 2022-6-9 14:06 编辑
  1. /* =========================================================================
  2. ; File:          main.asm (NY8A053E LVD function can't emulate in NY8_ICE. This function must be verification in real chip. )
  3. ; Description:   This Project teaches how to set LVD
  4. ;                1. FINST = 4MHz/4T(I_HRC)
  5. ;                2. Set LVD vlotage is 2.8V,
  6. ;                   PB0 polling with SFR bit "LVDOUT" at PCON1[6]. When VDD voltage below LVD voltage, then PB0 output low.
  7. ;                           
  8. ;                                         2.1 Using Power noise bypass capacitor between VDD and GND (0.1uF)
  9. ;                                        2.2 Set CMPCR[3:0] : 1010  
  10. ;                                        2.3 LVDS[3:0]    0000 => 1.9V
  11. ;                                                                         0001 => 2.0V
  12. ;                                                                         0010 => 2.2V
  13. ;                                                                         0011 => 2.4V
  14. ;                                                                         0100 => 2.6V                                                
  15. ;                                                                         0101 => 2.8V
  16. ;                                                                         0110 => 2.9V
  17. ;                                                                         0111 => 3.0V
  18. ;                                                                         1000 => 3.15V
  19. ;                                                                         1001 => 3.3V
  20. ;                                                                         1010 => 3.45V
  21. ;                                                                         1011 => 3.6V
  22. ;                                                                         1100 => 3.75V
  23. ;                                                                         1101 => 3.9V
  24. ;                                                                         1110 => 4.05V
  25. ;                                                                         1111 => 4.15V
  26. ;                     
  27. ; Author:        JasonLee
  28. ; Version:       V1.0
  29. ; Date:          2020/08/05
  30. =========================================================================*/
  31. #include <ny8.h>
  32. #include "ny8_constant.h"

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

/* =========================================================================
; 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

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

7

主题

18

帖子

1

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