??? 06/09/12 10:59 Read: times |
#187645 - need help - 93c46 using AT89s52 - mikroc Responding to: ???'s previous message |
good day Mr. Michael karas..
thanks for the advise.. FYI, this EEPROM is o/b already and the said code is working with Keil... but when i ports it through MikroC, it compiles but don't work... i have matched steps with the keil... but i don't understand why all segments brights up.. instead of giving numbers as output. for sure, timing is the only problem. but unfortunately, am new bee any have no oscilloscope. here is the keil code -- ... #include <reg51.h> #include <intrins.h> //define OP code #define OP_EWEN_H 0x00 // 00 write enable #define OP_EWEN_L 0x60 // 11X XXXX write enable #define OP_EWDS_H 0x00 // 00 disable #define OP_EWDS_L 0x00 // 00X XXXX disable #define OP_WRITE_H 0x40 // 01 A6-A0 write data #define OP_READ_H 0x80 // 10 A6-A0 read data #define OP_ERASE_H 0xc0 // 11 A6-A0 erase a word #define OP_ERAL_H 0x00 // 00 erase all #define OP_ERAL_L 0x40 // 10X XXXX erase all #define OP_WRAL_H 0x00 // 00 write all #define OP_WRAL_L 0x20 // 01X XXXX write all //define pin sbit CS = P3^7; sbit SK = P3^6; sbit DI = P3^5; sbit DO = P3^4; unsigned char code dis_code[] = { 0x28, 0x7E, 0xA2, 0x62, 0x74, 0x61, 0x21, 0x7A, 0x20, 0x60,0xff};//0,1,2,3,4,5,6,7,8,9,Guan, the digital code table unsigned char display[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; void start(); void ewen(); void ewds(); void erase(); void write(unsigned char addr, unsigned char indata); unsigned char read(unsigned char addr); void inop(unsigned char op_h, unsigned char op_l); void shin(unsigned char indata); unsigned char shout(); void delayms(unsigned int ms); //********************************************************* char code SST516[3] _at_ 0x003b; main() { unsigned char i,shift; CS = 0; //Initialization port SK = 0; DI = 1; DO = 1; ewen(); // So as to write erase(); // Erasing all the contents of for(i = 0 ; i < 8; i++) //Write code to show AT93C46 { write(i, dis_code[i]); } ewds(); // Prohibition of write - for(i = 0 ; i < 8; i++) { display[i]=read(i); // Read AT93C46 content } while(1) { shift=0x7f; P2=0xff ; for(i=0; i<8; i++) { P0=display[i]; P2=shift; shift=_cror_(shift,1); delayms(400); //Paoma Deng display } } } //********************************************************* void write(unsigned char addr, unsigned char indata) // Indata write data to addr { inop(OP_WRITE_H, addr); // Written instructions and addresses shin(indata); CS = 0; delayms(10); // Twp } //********************************************************* unsigned char read(unsigned char addr) // Read the data addr { unsigned char out_data; inop(OP_READ_H, addr); //Written instructions and addresses out_data = shout(); CS = 0; return out_data; } //********************************************************* void ewen() { inop(OP_EWEN_H, OP_EWEN_L); CS= 0; } //********************************************************* void ewds() { inop(OP_EWDS_H, OP_EWDS_L); CS= 0; } //********************************************************* void erase() { inop(OP_ERAL_H, OP_ERAL_L); delayms(30); CS = 0; } //********************************************************* void inop(unsigned char op_h, unsigned char op_l) //Op_h moved into the two high and the low seven op_l //op_h script for the two high //op_l script for the low seven or seven address { unsigned char i; SK = 0; // Start - DI = 1; CS = 1; // _nop_(); // _nop_(); SK = 1; // _nop_(); // _nop_(); SK = 0; // The beginning of the end DI = (bit)(op_h & 0x80); // High into the first script SK = 1; op_h <<= 1; SK = 0; DI = (bit)(op_h & 0x80); // Into the script, high SK = 1; // _nop_(); // _nop_(); SK = 0; // Into the rest of the script or address data op_l <<= 1; for(i = 0; i < 7; i++) { DI = (bit)(op_l & 0x80);// First moved into high SK = 1; op_l <<= 1; SK = 0; } DI = 1; } //********************************************************* void shin(unsigned char indata) //Inflow data { unsigned char i; for(i = 0; i < 8; i++) { DI = (bit)(indata & 0x80);// First moved into high SK = 1; indata <<= 1; SK = 0; } DI = 1; } //********************************************************* unsigned char shout(void) // Data out { unsigned char i, out_data; for(i = 0; i < 8; i++) { SK = 1; out_data <<= 1; SK = 0; out_data |= (unsigned char)DO; } return(out_data); } //********************************************************* void delayms(unsigned int ms) //Delay subroutine { unsigned char i; while(ms--) { for(i = 0; i < 120; i++); } } ...insert code here ...insert code here ...insert code here |
Topic | Author | Date |
help me with 93c46 and at89s52---MikroC | 01/01/70 00:00 | |
What You Need to Do Yourself | 01/01/70 00:00 | |
need help - 93c46 using AT89s52 - mikroc | 01/01/70 00:00 | |
MikroC is unwise choice | 01/01/70 00:00 | |
help me with 93c46 and at89s52---MikroC | 01/01/70 00:00 | |
So check without scope - adjust code until testable | 01/01/70 00:00 | |
you have now 3 times asked help with 93c46/at89s52--MikroC | 01/01/70 00:00 | |
93c46/at89s52--MikroC | 01/01/70 00:00 | |
my suggestion | 01/01/70 00:00 | |
You have already been given suggestions | 01/01/70 00:00 | |
help me with 93c46 and at89s52---MikroC | 01/01/70 00:00 | |
Use a proper Compiler | 01/01/70 00:00 | |
I wanna, I wanna, I wanna, | 01/01/70 00:00 | |
Time to actually prove your logic and your delays | 01/01/70 00:00 | |
----thanks all for helping out | 01/01/70 00:00 | |
do you REALLY expect .... | 01/01/70 00:00 | |
If you can't get MikroC to work ... | 01/01/70 00:00 | |
switching to keil | 01/01/70 00:00 | |
Example code on this website | 01/01/70 00:00 | |
why, oh why | 01/01/70 00:00 |