+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 5
    Points: 1,885, Level: 10

    Join Date
    Sep 2010
    Posts
    279
    Helped
    6 / 6
    Points
    1,885
    Level
    10

    How to debug/Test SPI Communication PIC16F628A & NRF24L01+ (software SPI)

    Hi,

    I have been trying from last many days regarding the communication between PIC16F628A (my mcu) and NRF24L01+ communication module. But i am unsuccessful.. i am not having any idea whether the data is written into the NRF24L01+ register or not ?

    So is there any methods available for SPI Debug ? I have pickit3, MPLAB X IDE 1.90, MPLAB IDE v8.92 and Mikroc Pro v6.0.0 how can i simply check whether the sPI communication is perfect or not ?

    Thanks.

    Here's My NRF24L01+ Receiver side code :
    Code:
    #include 
    
    __CONFIG(FOSC_EXTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & BOREN_OFF & LVP_OFF & CPD_OFF & CP_OFF); //16F628A
    
    #include "stdint.h"
    /* Memory Map */
    #define CONFIG      0x00
    #define EN_AA       0x01
    #define EN_RXADDR   0x02
    #define SETUP_AW    0x03
    #define SETUP_RETR  0x04
    #define RF_CH       0x05
    #define RF_SETUP    0x06
    #define STATUS      0x07
    #define OBSERVE_TX  0x08
    #define CD          0x09
    #define RX_ADDR_P0  0x0A
    #define RX_ADDR_P1  0x0B
    #define RX_ADDR_P2  0x0C
    #define RX_ADDR_P3  0x0D
    #define RX_ADDR_P4  0x0E
    #define RX_ADDR_P5  0x0F
    #define TX_ADDR     0x10
    #define RX_PW_P0    0x11
    #define RX_PW_P1    0x12
    #define RX_PW_P2    0x13
    #define RX_PW_P3    0x14
    #define RX_PW_P4    0x15
    #define RX_PW_P5    0x16
    #define FIFO_STATUS 0x17
    #define DYNPD       0x1C
    
    /* Bit Mnemonics */
    
    /* configuratio nregister */
    #define MASK_RX_DR  6
    #define MASK_TX_DS  5
    #define MASK_MAX_RT 4
    #define EN_CRC      3
    #define CRCO        2
    #define PWR_UP      1
    #define PRIM_RX     0
    
    /* enable auto acknowledgment */
    #define ENAA_P5     5
    #define ENAA_P4     4
    #define ENAA_P3     3
    #define ENAA_P2     2
    #define ENAA_P1     1
    #define ENAA_P0     0
    
    /* enable rx addresses */
    #define ERX_P5      5
    #define ERX_P4      4
    #define ERX_P3      3
    #define ERX_P2      2
    #define ERX_P1      1
    #define ERX_P0      0
    
    /* setup of address width */
    #define AW          0 /* 2 bits */
    
    /* setup of auto re-transmission */
    #define ARD         4 /* 4 bits */
    #define ARC         0 /* 4 bits */
    
    /* RF setup register */
    #define PLL_LOCK    4
    #define RF_DR_HIGH  3
    #define RF_PWR      1 /* 2 bits */
    
    /* general status register */
    #define RX_DR       6
    #define TX_DS       5
    #define MAX_RT      4
    #define RX_P_NO     1 /* 3 bits */
    #define TX_FULL     0
    
    /* transmit observe register */
    #define PLOS_CNT    4 /* 4 bits */
    #define ARC_CNT     0 /* 4 bits */
    
    /* fifo status */
    #define TX_REUSE    6
    #define FIFO_FULL   5
    #define TX_EMPTY    4
    #define RX_FULL     1
    #define RX_EMPTY    0
    
    /* dynamic length */
    #define DPL_P0      0
    #define DPL_P1      1
    #define DPL_P2      2
    #define DPL_P3      3
    #define DPL_P4      4
    #define DPL_P5      5
    
    /* Instruction Mnemonics */
    #define R_REGISTER    0x00 /* last 4 bits will indicate reg. address */
    #define W_REGISTER    0x20 /* last 4 bits will indicate reg. address */
    #define REGISTER_MASK 0x1F
    #define R_RX_PAYLOAD  0x61
    #define W_TX_PAYLOAD  0xA0
    #define FLUSH_TX      0xE1
    #define FLUSH_RX      0xE2
    #define REUSE_TX_PL   0xE3
    #define ACTIVATE      0x50
    #define R_RX_PL_WID   0x60
    //#define NOP           0xFF
    
    
    
    /// hardware spi pin defined
    #define LED_PIN      PORTBbits.RA1 // led test
    #define CS_Pin       PORTBbits.RB0//          //set port as output
    #define CE_Pin       PORTBbits.RB4         //set port as output
    #define SCK_Pin      PORTBbits.RB1        //set port as output
    #define Mosi_Pin     PORTBbits.RB2         //set port as output
    #define Miso_Pin     PORTBbits.RB3        //set port as input
    #define HIGH         1
    #define LOW          0
    
    //#ifndef NRF24
    #define NRF24
    
    //#include "nRF24L01.h"
    //#include 
    
    #define LOW 0
    #define HIGH 1
    
    #define nrf24_ADDR_LEN 5
    #define nrf24_CONFIG ((1<
    

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 3
    Points: 3,983, Level: 14
    embpic's Avatar
    Join Date
    May 2013
    Location
    india
    Posts
    742
    Helped
    80 / 80
    Points
    3,983
    Level
    14

    Re: How to debug/Test SPI Communication PIC16F628A & NRF24L01+ (software SPI)

    yes you can try proteus to check SPI behavior bcoz it contains SPI debug facility.
    Thanks & Regards,
    embpic



    •   AltAdvertisement

        
       

  3. #3
    Full Member level 5
    Points: 1,885, Level: 10

    Join Date
    Sep 2010
    Posts
    279
    Helped
    6 / 6
    Points
    1,885
    Level
    10

    Re: How to debug/Test SPI Communication PIC16F628A & NRF24L01+ (software SPI)

    how can you tell me how to do it using proteus ?



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 3
    Points: 3,983, Level: 14
    embpic's Avatar
    Join Date
    May 2013
    Location
    india
    Posts
    742
    Helped
    80 / 80
    Points
    3,983
    Level
    14

    Re: How to debug/Test SPI Communication PIC16F628A & NRF24L01+ (software SPI)

    as you need to debug the SPI communication of PIC16F628a and NRF24L01 then proteus is good option bcoz you check the actual data is transmitting.
    Thanks & Regards,
    embpic



  5. #5
    Advanced Member level 4
    Points: 11,287, Level: 25
    Kripton2035's Avatar
    Join Date
    Jul 2001
    Location
    Western Europe
    Posts
    1,147
    Helped
    206 / 206
    Points
    11,287
    Level
    25

    Re: How to debug/Test SPI Communication PIC16F628A & NRF24L01+ (software SPI)

    Microchip’s In-Circuit Debugger, MPLAB ICD 2, is a powerful, low-cost, run-time development tool, connecting to the host PC via an RS-232 or high-speed USB interface. This tool is based on the Flash PIC MCUs and can be used to develop for these and other PIC MCUs and dsPIC DSCs. The MPLAB ICD 2 utilizes the in-circuit debugging capability built into the Flash devices. This feature, along with Microchip’s In-Circuit Serial ProgrammingTM (ICSPTM) protocol, offers cost- effective, in-circuit Flash debugging from the graphical user interface of the MPLAB Integrated Development Environment. This enables a designer to develop and debug source code by setting breakpoints, single step- ping and watching variables, and CPU status and peripheral registers. Running at full speed enables testing hardware and applications in real time. MPLAB ICD 2 also serves as a development programmer for selected PIC devices.



--[[ ]]--