问答

汇集网友智慧,解决技术难题

21ic问答首页 - 谁能帮我看看n76e003可调电源的程序

N76E003 可调电源 include ADC dc

谁能帮我看看n76e003可调电源的程序

1716503332020-11-16
开机后oled上ADC电压值有变化,旋转编码器后,oled就显示一个值没有变化
#include <stdio.h>
#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_Define.h"
#include "oled.h"
#include "bmp.h"

UINT8 temp=0xD7;
UINT8 temp1=0x02;

void ADC_ISR (void) interrupt 11
{
        if(ADCF)
        {
                clr_ADCF;
                set_ADCS;
//printf ("\n Value = 0x%bx",ADCRH);
        }
}

void show()
    {
         uint16_t BandGap_H, BandGap_L,BandGap_v;
         uint16_t  voltage = 0;
          char aa[10];
          float  v;
                BandGap_H = ADCRH;
                BandGap_L = ADCRL;
                BandGap_v = BandGap_H << 4 | BandGap_L;
                v=(float)BandGap_v*(3.3/4096);
                v*=10;       
          sprintf(aa,"%5.2f",v);
                OLED_ShowString(0,0,aa);
                }
       

void main (void)
{
//        unsigned char t;
//        uint16_t BandGap_H, BandGap_L,BandGap_v,temp;
//        uint16_t  voltage = 0;
//       
//        char aa[10];
//        float  v;
        Set_All_GPIO_Quasi_Mode;                                        // Define in Function_define.h
        P17_Input_Mode;
        P30_Input_Mode;
        set_EPI;       
        clr_PIPS1;
        set_PIPS0;
  Enable_BIT7_RasingEdge_Trig;

        Enable_ADC_AIN2;                                                                                                                // Enable AIN0 P1.7 as ADC input
  set_EADC;                                                                                                                                                // Enable ADC interrupt (if use interrupt)


       
        set_EPWM;//??
        PWM_INT_PWM4;
  PWM_FALLING_INT;
        PWM4_P01_OUTPUT_ENABLE;

  clr_PWMTYP;//??????
  clr_PWMMOD0;//?????????
  clr_PWMMOD1;  
       
  PWM_CLOCK_DIV_8;//8????
  PWMPH = 0x07;                                                                                                                                //Setting PWM value         
        PWMPL = 0xCF;
        set_SFRPAGE;//PWM4 and PWM5 duty seting is in SFP page 1
  PWM4H = 0x02;//500(Dec)               
  PWM4L = 0xD7;
        clr_SFRPAGE;     
        set_LOAD;                                                                                                                                                // PWM run
        set_PWMRUN;
       
        set_EA;       
        set_ADCS;
        InitialUART0_Timer3(115200);
        set_CLOEN;  
        OLED_Init();                        //³õʼ»¯OLED  
       
        //        t=' ';

  while(1)
  {          
        show();
        Timer0_Delay1ms(300);
       
        }          
       
}
void PWMISR() interrupt 13
{
        if(PWMF)//????????
        {
                  clr_LOAD;//????????
                  clr_PWMF;//??PWM?????   
                        set_SFRPAGE;//PWM4 and PWM5 duty seting is in SFP page 1
                   PWM4H=temp1;
                   PWM4L=temp;
                clr_SFRPAGE;   
                set_LOAD;//????,????
                clr_PWMF;
        }
}

void PinInterrupt (void) interrupt 7
{
                if(PIF==0x80&&P17)
                {
                        Timer0_Delay1ms(1);
                        if(P17)
                        {
                                if(P30)
                                {
                  temp+=30;
                                        if(temp<30)
               {
                                                         if(temp1==7){temp=0xc0;}else{temp1+=1;}}
                        //Timer0_Delay1ms(500);
                                                         }   
                                else{
           temp-=30;
                                        if(temp<30){
                                        if(temp1==0){temp=0x30;}else{temp1-=1;temp=0xff;}}
                        //Timer0_Delay1ms(500);  
                                        }
                        }       
                }
                                PIF=0;
        PWMF=1;
}
回答 +关注 9
618人浏览 4人回答问题 分享 举报
4 个回答

您需要登录后才可以回复 登录 | 注册