??? 01/22/09 11:48 Read: times Msg Score: -1 -1 Message Not Useful |
#161696 - My code related to FX604 (check it) Responding to: ???'s previous message |
Hey!
I have written some test codes for the Transmitter and Receiver sides. I have studied the datasheet thoroughly, still am not so clear. Plz guide me, I am really worried. Here are both codes. 1) Transmitter Code: #include <AT892051.H> #include <intrins.h> sbit RXD1 = P3^0; sbit TXD1 = P3^1; sbit M0 = P3^2; sbit M1 = P3^3; sbit CLK = P3^4; sbit RDYN = P3^7; void send (void); unsigned char bdata value = 0; bit flag; sbit value_0 = value^0; sbit value_1 = value^1; sbit value_2 = value^2; sbit value_3 = value^3; sbit value_4 = value^4; sbit value_5 = value^5; sbit value_6 = value^6; sbit value_7 = value^7; void main() { M1 = 0; //for Tx mode M0 = 1; P1 = 0xFF; flag = 1; _nop_(); _nop_(); while(flag) { if(P1_0 == 0) // Push Button 1 { value=0xEE; } else if(P1_1 == 0) // Push Button 2 { value=0xDD; } else if(P1_2 == 0) // Push Button 3 { value=0xBB; } else if(P1_3 == 0) // Push Button 4 { value=0x77; } else { value=0xFF; } send(); } } void send (void) { //send routine start CLK = 0; _nop_(); _nop_(); while(RDYN); // Check for RDYN transition _nop_(); TXD1 = value_0; CLK = 1; _nop_(); _nop_(); _nop_(); CLK = 0; _nop_(); _nop_(); while(RDYN); // Check for RDYN transition _nop_(); TXD1 = value_1; CLK = 1; _nop_(); _nop_(); _nop_(); CLK = 0; _nop_(); _nop_(); while(RDYN); // Check for RDYN transition _nop_(); TXD1 = value_2; CLK = 1; _nop_(); _nop_(); _nop_(); CLK = 0; _nop_(); _nop_(); while(RDYN); // Check for RDYN transition _nop_(); TXD1 = value_3; CLK = 1; _nop_(); _nop_(); _nop_(); CLK = 0; P1 = 0xFF; } //send routine end 2) Now Receiver's Code: #include <AT892051.h> #include <intrins.h> sbit RXD1 = P3^0; sbit TXD1 = P3^1; sbit M0 = P3^2; sbit M1 = P3^3; sbit CLK = P3^4; sbit RDYN = P3^7; void delay(int m); void receive(void); bit flag; void main() { M1 = 1; // for Rx mode M0 = 0; P1 = 0xFF; flag = 1; while(flag) { while(RDYN); receive(); } } void delay(int m) { int c,d; for(d=0;d<m;d++) { for(c = 0;c < 150;c++) _nop_(); } } void receive(void) { CLK = 0; _nop_(); _nop_(); P1_0 = RXD1; _nop_(); _nop_(); CLK = 1; delay(1); CLK = 0; _nop_(); _nop_(); P1_1 = RXD1; _nop_(); _nop_(); CLK = 1; delay(1); CLK = 0; _nop_(); _nop_(); P1_2 = RXD1; _nop_(); _nop_(); CLK = 1; delay(1); CLK = 0; _nop_(); _nop_(); P1_3 = RXD1; _nop_(); _nop_(); CLK = 1; delay(1); } |
Topic | Author | Date |
Need help on FX604 usage. | 01/01/70 00:00 | |
What is FX604? | 01/01/70 00:00 | |
He's talking about "SPI Bell 202 modem" | 01/01/70 00:00 | |
My code related to FX604 (check it)![]() | 01/01/70 00:00 |