| ??? 06/03/12 16:29 Read: 734 times |
#187607 - help me with 93c46 and at89s52---MikroC |
sir, please help as am unable to get the desired output from the code below in Mikro C for 8051--
//define pin sbit Chip_Select at P3.B7; sbit SoftSpi_CLK at P3.B6; sbit SoftSpi_SDI at P3.B5; sbit SoftSpi_SDO at P3.B4; unsigned char i; void OP_ER_Enable(){ Chip_Select=1; Soft_SPI_Write(1); Soft_SPI_Write(0); Soft_SPI_Write(0); Soft_SPI_Write(0x60); Chip_Select=0; //DI=0; } void OP_Clear_Chip(){ Chip_Select=1; Soft_SPI_Write(1); Soft_SPI_Write(0); Soft_SPI_Write(0); Soft_SPI_Write(0x40); Delay_ms(30); Chip_Select=0; //DI=0; } void WR_to_Chip(){ Chip_Select=1; Soft_SPI_Write(1); Soft_SPI_Write(0); Soft_SPI_Write(1); Soft_SPI_Write(0x00); Soft_SPI_Write(0x28); Chip_Select=0; //DI=0; } unsigned char Read_from_Chip(){ unsigned char dtt=0; Chip_Select=1; Soft_SPI_Write(1); Soft_SPI_Write(1); Soft_SPI_Write(0); Soft_SPI_Write(0x00); i=0; while(i<8) { dtt |= SoftSpi_SDO; dtt <<= 1; i++; } return dtt; Chip_Select=0; //DI=0; } void main() { Soft_SPI_Init(); OP_ER_Enable(); //Delay_ms(30); OP_Clear_Chip(); WR_to_Chip(); Delay_ms(30); P0 = ~Read_from_Chip(); while(1) { //P2=0xff ; for(i=0; i<8; i++) { P2=0xFE; delay_ms(400); } } } at the moment, all the segments are being lighted.. |



