RP Store Tìm linh kiện theo mã, gửi BOM nhận báo giá Gửi BOM

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

Collapse
X
 
  • Giờ
  • Show
Clear All
new posts
  • iVoVa
    Nhập môn đệ tử
    • Mar 2011
    • 6

    #1

    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);    
        }
    
    } 
    



    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
    Nhập môn đệ tử
    • Mar 2011
    • 6

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

    Comment

    Working...