程序

#ifndef main_c   //test ok
  #define main_c
#endif 

#include "main.h"
//************************全局变量

volatile uint t0_cont;

volatile uint t1_cont;
volatile uchar flg1; //
//-------------------------------------------------------------------------
//     测试函数 用来初始化
//-------------------------------------------------------------------------
void test()
{
  send_str( "pinlvji" ); //完成后把所有串口去掉
  showstr( "cymometer", 1, 1, 9 ); //液晶显示
//  showstr( "1KHz", 12, 1, 4 );
  showstr( "Hz", 14, 2, 2 );
}

//-------------------------------------------------------------------------
//mcu初始化 端口 定时器 中断 外中断 变量
//-------------------------------------------------------------------------
void mcu_init()
{
//******************端口
  data_direc = out; //输出
  DDRB = out; //输出
  DDRC = out; //输出
  PORTC = 0X00; //输出0

  DDRB=0XE0;   //输入口       
  PORTB=0XE9;
//********************定时器
  TIMSK |= 0x12; //定时中断允许位 只允许两个匹配
}

//-------------------------------------------------------------------------
//       主函数 
//-------------------------------------------------------------------------
int main()
{
  uchar f_t; //用测频还是测周
//******************
  mcu_init();                 //初始化
  usart_init( 57600 );        //初始化
  send_str( "com ok" ); //完成后把所有串口去掉
  yj_set( 0x38, 0x0f, 0x06 ); //初始化
  clearall(); //初始化
  mzd_on();   //开中断

  #if debug
    test();
  #endif 

  while ( 1 )
  {
    if ( !( PINB& ( 1 << 3 )))
    {
      refish();       //刷新所有的东西
      f_t = hz_try(); //估计范围 1k
      if ( f_t )
      {
        cl_f(); //频率法
      }
      else
      {
        cl_t(); //周期法
      }
    }
  }
  return 1;
}

protues仿真

基于单片机的智能频率计的设计_毕业设计


全套资料免费下载:

关注v-x-公-众-号:【嵌入式基地

后-台-回-复:【毕业设计】 即可获资料

回复【编程】即可获取

包括有:C、C++、C#、JAVA、Python、JavaScript、PHP、数据库、微信小程序、人工智能、嵌入式、Linux、Unix、QT、物联网、算法导论、大数据等资料

基于单片机的智能频率计的设计_单片机_02