标题: nxp LPC935芯片 求高手帮忙看下程序的问题点在哪里? [打印本页]

作者: adeyan    时间: 2020-6-29 22:50
标题: nxp LPC935芯片 求高手帮忙看下程序的问题点在哪里?
//利用nxp LPC935产生300HZ占空比为30%的6路脉冲
晶振频率6MHz


#include "reg935.h"
sbit LED=P0^7;          //吸料指示灯               
sbit pls_1=P0^6;        //脉冲1
sbit pls_2=P0^5;        //脉冲2
sbit pls_3=P0^4;        //脉冲3
sbit pls_4=P0^3;        //脉冲4
sbit pls_5=P0^2;        //脉冲5
sbit pls_6=P0^1;        //脉冲6                        
unsigned int k,l;
unsigned char PWM_COUNT;
void timer0_init();
/****************************************************
*                                   采用定时器2
                   工作方式2,每 0.33us 中断一次
*
*****************************************************/
void timer0_init()
{
  TMOD|=0X02;
  TH0=0X38;// 200个扫描周期既66.66u中断一次,总共中断50次
  TL0=0X38;
  TR0=1;
  ET0=1;
  EA=1;
  PWM_COUNT=0;
}


void main()
{
  timer0_init();

while(1)   
{
P0M1=0x00; //推挽输出
P0M2=0xff;  //推挽输出
pls_1=0;
pls_2=0;
pls_3=0;
pls_4=0;
pls_5=0;
pls_6=0;

}
}
/****************************************************
*                                   中断服务子函数

*
*****************************************************/
void timer0() interrupt 1
{
  PWM_COUNT++;

                        
if(PWM_COUNT==15)
{
pls_1=0;
pls_2=0;
pls_3=0;
pls_4=0;
pls_5=0;
pls_6=0;
}
  if(PWM_COUNT==50)
{
pls_1=1;
pls_2=1;
pls_3=1;
pls_4=1;
pls_5=1;
pls_6=1;
PWM_COUNT=0;//从新计时






}
}



作者: hsl32    时间: 2020-6-30 08:56
问题出在while(1),把里面的程序放在while(1)前面,while(1);直接是空的。




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1