Home > other >  In the keil programming, uchar I... The eight variables, global can be successful, but to function i
In the keil programming, uchar I... The eight variables, global can be successful, but to function i

Time:12-31

#include
#include
# define uchar unsigned char
# define uint unsigned int
Sbit PSB=P0 ^ 5;
Sbit RESET=P0 ^ 6;
CS=sbit P0 ^ 2;
Sbit SID=P0 ^ 3;
Sbit SCLK=P0 ^ 4;

Void init (void);
Void write_command (uchar w1);
Void write_data (uchar w2);
Void main (void)
{

}
Void init (void)
{
PSB=0;
RESET=1;
}
Void write_command (uchar w1)//write instructions
{
CS=1;

Temp1=0 xf8;
for(i=0; i<8; I++)
{
SID=(temp1 & amp; 0 x80);
SCLK=0;
SCLK=1;
Temp1=(temp1 & lt; <1);
}
Temp2=w1.
Temp2=(temp2 & amp; 0 xf0);
for(i=0; i<8; I++)
{
SID=(w1 & amp; 0 x80);
SCLK=0;
SCLK=1;
Temp2=(temp2 & lt; <1);
}
Temp3=w1;
Temp3=(temp3 & amp; 0 x0f);
for(i=0; i<8; I++)
{
SID=(temp3 & amp; 0 x80);
SCLK=0;
SCLK=1;
Temp3=(temp3 & lt; <1);
}
}
The void write_data (uchar w2)//write data
{
CS=1;

Data1=0 xfa;
For (a=0; a<8; +)
{
SID=(data1 & amp; 0 x80);
SCLK=0;
SCLK=1;
Data1=(data1 & lt; <1);
}
Data2=(w2 & amp; 0 xf0);
for(i=0; i<8; I++)
{
SID=(data2 & amp; 0 x80);
SCLK=0;
SCLK=1;
Data2=(data2 & lt; <1);
}
Data3=(w2 & amp; 0 x0f);
for(i=0; i<8; I++)
{
SID=(data3 & amp; 0 x80);
SCLK=0;
SCLK=1;
Data3=(data3 & lt; <1);
}
}
  • Related