PIC Vietnam

PIC Vietnam (http://www.picvietnam.com/forum/index.php)
-   Các ngôn ngữ lập trình khác (CCS C, HT PIC,...) (http://www.picvietnam.com/forum/forumdisplay.php?f=12)
-   -   Xem giúp lỗi giao tiếp SPI của 2 PIC18 ! (http://www.picvietnam.com/forum/showthread.php?t=8067)

iVoVa 15-03-2011 02:14 AM

Xem giúp lỗi giao tiếp SPI của 2 PIC18 !
 
PHP Code:


#include<18F4520.h>
#use delay(clock=4000000)
#use FAST_IO(D)

void main()
{
    
int8 number;
    
setup_spi(SPI_MASTER );
    while(
1)
    {
        
number input_D();
        
spi_write(number);
    }
     
    



PHP Code:

#include<18F4520.h>
#use delay(clock=4000000)
#use FAST_IO( D)


void main()
{
    
int8 number;
    
setup_spi(SPI_SLAVE );
    while(
1)
    {
        
number spi_read();
        
output_D(num);    
    }




http://cB1.upanh.com/20.69.26957410.EsK0/spidesign.jpg

Mình dùng 2 PIC8F4520 giao tiếp SPI, Master nhận dữ liệu từ portB sau đó gởi đến Slaver, Slaver đọc dữ liệu và xuất ra lại PORTD.
Không hiểu sao ở PORTD của Slave nó không thay đổi giá trị khi mình thay đổi giá trị dữ liệu vào của Master.
Mình tìm hoài mà ko biết lỗi gì,xin nhờ giúp đỡ.

iVoVa 15-03-2011 05:26 PM

Đã sửa lỗi được.


Múi giờ GMT. Hiện tại là 05:40 PM.

Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam