![]() |
|
|
#1 |
|
Nhập môn đệ tử
Tham gia ngày: May 2008
Bài gửi: 8
: |
Debug SPI using Mikro C/Proteus
Mình có code 1 đoạn SPI (Mater mode) dùng Mikro C cho PIC6f877
Code:
void main()
{
ADCON1=0x06; //RA5 Digital I/O
TRISA=0x00; //!RA5=SS: output for Chip Select
TRISC=0x10; //RC5:output SDO
//RC4: Input SDI
//RC3:output SCK
Spi_Init();
PORTA.F5=0; //!SS=0 chip enabled
Spi_Write(0x20); // Power up
Spi_Write(0x00);
Delay_ms(25); //Tpud
Spi_Write(0x20); //Power up
Spi_Write(0x00);
Delay_ms(50); //2 x Tpud
Spi_Write(0xB0); //SETREC from location 0x00
Spi_Write(0x00);
Delay_ms(10000); //delay 10s for recording
Spi_Write(0x30); //STOP
Spi_Write(0x00);
Delay_ms(50); //Tstop;
}
Mình có thử dùng Proteus/SPI debugger dể test,nhưng ko thực sự rành lắm, với lại ko hiểu sao lại xuất hiện Bit -1 https://www.yousendit.com/download/b...ZDVYSHpIRGc9PQ file .DSN https://www.yousendit.com/download/b...ckk5eFVLSkE9PQ file .PWI https://www.yousendit.com/download/b...cklFd2NLSkE9PQ file .HEX Schemantics: ![]() |
|
|
|
![]() |
| Ðiều Chỉnh | |
| Xếp Bài | |
|
|