📄 canshu.c
字号:
//2. MAX261参数f0,Q写入程序:
#include <REG51.H> /* special function register declarations */
/* for the intended AT89C2051 derivative */
#include <stdio.h> /* prototype declarations for I/O functions */
sbit P1_0=P1^0; /* /RESET connect to P1^0 */
sbit P1_2=P1^2; /* D1 connect to P1^2 */
sbit P1_3=P1^3; /* D0 connect to P1^3 */
sbit P1_4=P1^4; /* A3 connect to P1^4 */
sbit P1_5=P1^5; /* A2 connect to P1^5 */
sbit P1_6=P1^6; /* A1 connect to P1^6 */
sbit P1_7=P1^7; /* A0 connect to P1^7 */
sbit P3_7=P3^7; /* /WR connect to P3^7 */
/*------------------------------------------------
The main C function. Program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void) {
int i;
int a[8];
for(i=0;i<8;i++)
a[i]=i;
printf("please enter number 0 to 8 by order to set MAX261: ");
for(i=0;i<8;i++)
scanf("%d",&a[i]);
P1_0=1; // /RESET=1 to make 7555 oscillator work normally
P3_7=1;
/*------------------------------------------------
The following program section realize the function of setting f0A=1125.4HZ,
QA=90.5 of MAX261.
------------------------------------------------*/
switch (a[i]) {
/*------------------------------------------------
The following program section realize the function of selecting mode2 to the filter A of MAX261
and setting F5aF4aF3aF2aF1aF0a=001000B,Q6aQ5aQ4aQ3aQ2aQ1aQ0a=1111111B
------------------------------------------------*/
case '0':
P3_7=0; // the falling edge of /WR
//p1=0x08;
P1_2=0; //select mode 2,set M1a=0
P1_3=1; //set M0a=1
P1_4=0;
P1_5=0;
P1_6=0;
P1_7=0; //address A3 A2 A1 A0=0x0
P3_7=1;
case '1':
P3_7=0; //the falling edge of /WR
P1_2=0; //set F1a=0
P1_3=0; //set F0a=0
P1_4=0;
P1_5=0;
P1_6=0;
P1_7=1; //address A3 A2 A1 A0=0x1
P3_7=1;
case '2':
P3_7=0; //the falling edge of /WR
P1_2=1; //set F3a=1
P1_3=0; //set F2a=0
P1_4=0;
P1_5=0;
P1_6=1;
P1_7=0; //address A3 A2 A1 A0=0x2
P3_7=1;
case '3':
P3_7=0; //the falling edge of /WR
P1_2=0; //set F5a=0
P1_3=0; //set F4a=0
P1_4=0;
P1_5=0;
P1_6=1;
P1_7=1; //address A3 A2 A1 A0=0x3
P3_7=1;
case '4':
P3_7=0; //the falling edge of /WR
P1_2=1; //set Q1a=1
P1_3=1; //set Q0a=1
P1_4=0;
P1_5=1;
P1_6=0;
P1_7=0; //address A3 A2 A1 A0=0x4
P3_7=1;
case '5':
P3_7=0; //the falling edge of /WR
P1_2=1; //set Q3a=1
P1_3=1; //set Q2a=1
P1_4=0;
P1_5=1;
P1_6=0;
P1_7=1; //address A3 A2 A1 A0=0x5
P3_7=1;
case '6':
P3_7=0; //the falling edge of /WR
P1_2=1; //set Q5a=1
P1_3=1; //set Q4a=1
P1_4=0;
P1_5=1;
P1_6=1;
P1_7=0; //address A3 A2 A1 A0=0x6
P3_7=1;
case '7':
P3_7=0; //the falling edge of /WR
P1_2=0;
P1_3=1; //set Q6a=1
P1_4=1;
P1_5=0;
P1_6=0;
P1_7=0; //address A3 A2 A1 A0=0x7
P3_7=1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -