Jump to content
  • 0

Basys 2 with PmodRF2 SPI communication


Harimaya

Question

Hi everyone :)

I have a school project with a Basys 2 FPGA board. The goal is to communicate between two of these boards with 2 PmodRF2 modules. So I have to use the SPI communication protocol. Our first goal is really simple : send one bit forma board to the other to light a LED on it.

But I only started to work on FPGA recently so it is kinda hard and I have basic questions.

1. Does the module handle all the "register and adresses" stuff with the MRF24J40 chip by itself ?

2. How do I set one board to be the master and the other to be the slave ?

I already did some research on the Internet but I didnt really found something to help me.

Thank you for your help :)

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Hi Harimaya,

So the short answer is that Digilent has not had the opportunity to devote enough time towards creating some demonstration code for the PmodRF2, and as you found, there isn't a whole lot online to help out.

In terms of your questions, and looking at the datasheet, the MRF24J40 chip by Microchip does not handle everything by itself. I do not know everything that would be involved with getting the module up and running, but at the very least it seems that you would need to go through the initialization sequence provided on page 90.

As for the master/slave portion, I do not think you would need to specify either. I'm certainly not an expert with wireless communication, but it seems to me that as a user (as per page 112) you would have to load appropriate data into a FIFO register and then set a different register bit to transmit the packet. The MRF24J40 appears to handle the transmission and various frames and also simultaneously monitors any incoming signals for valid incoming signals, so that once it finds one it places the data in a receive buffer and sets an interrupt flag (page 107). So, there does not seem to be a master/slave combination with RF communication.

However, that is the extent of my knowledge of RF and the PmodRF2 after having looked through the MRF24J40 datasheet. If you have any more questions, feel free to ask, but I personally can't promise that I will be able to answer.

Thanks,
JColvin

Link to comment
Share on other sites

Hi, thank you for your answer. I read the documentation a lot and tried to understand how the Microchip MRF24J40 works. Now I'm trying to make a basic register reading like its explained on the documentation (p14). But I can't read any register. I made a program to send a data with a 1Hz frequency in order to display the send and received data on LEDs. I tried to read some registers (like 0x2A or 0x18 etc ...), but I receive, nothing, could you help me please ? I post my code to help you.

 

----------------------------------------------------------------------------------
-- Company: 
-- IPSA: 
-- 
-- Create Date:    15:32:51 12/29/2015 
-- Design Name: 
-- Module Name:    main - Behavioral 
-- Project Name: 
-- Target Devices: 
-- Tool versions: 
-- Description: 
--
-- Dependencies: 
--
-- Revision: 
-- Revision 0.01 - File Created
-- Additional Comments: 
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity main is
    Port ( led : out  STD_LOGIC_VECTOR (2 downto 0);
           sck : out  STD_LOGIC;
			  reset : in STD_LOGIC;
			  C   : out	 STD_LOGIC_VECTOR (7 downto 0);
           clk : in  STD_LOGIC;
			  data_in : in STD_LOGIC;
			  cs : out STD_LOGIC;
			  cs_select : in STD_LOGIC;
			  bit1, bit8 : in STD_LOGIC;
           data_out:out STD_LOGIC);
end main;

architecture Behavioral of main is

SIGNAL cnt : INTEGER := 0 ;
SIGNAL clk_1Hz : STD_LOGIC ;
SIGNAL s_C : STD_LOGIC_VECTOR (7 downto 0) := "00000000";
SIGNAL addr : STD_LOGIC_VECTOR (5 downto 0) := "110110"; -- Adresse du registre à lire
SIGNAL s_cs : STD_LOGIC :='1';
-- Signaux utilisés pour la conversion parallèle série
signal DST:STD_LOGIC_VECTOR (5 downto 0):=(others=>'0');
signal DATA,STOP:STD_LOGIC:='0';
SIGNAL start : STD_LOGIC :='1';

begin

Process (clk) -- Génération clock 1Hz
Begin
If clk'event And clk = '1' Then

	if cnt = 50000000 then
		cnt <= 0;
		clk_1Hz <= '1';
		
	else
		cnt <= cnt +1;
		clk_1Hz <= '0';
		
	end if;
end if;
End Process;

-- Envoi de la sortie
Process (clk_1Hz)
begin
If (clk_1Hz'event AND clk_1Hz = '1') Then
	
	IF s_C = "00000000" THEN	
	
		s_C <= "11111111";
		
	ELSE
		
		s_C <= "00000000";
		
	END IF;		
	
end if;

End Process;

  process(reset,clk_1Hz)
       begin
             if reset='1' then
                   DST<=(others=>'0');
                   DATA<='0';
                   STOP<='0';
            elsif (clk_1Hz'event AND clk_1Hz = '0') then
						if cs_select ='0' then
						
							if start='1' then
								  DATA<= bit1;--start bit
								  STOP<= bit8;--stop bit
								  DST<=addr;  
								  start <= '0';
							else
								  DATA<=DST(5);
								  STOP<='0';
								  DST<=DST(4 downto 0)&STOP;
							end if;
						end if;
            end if;
      end process;
		
data_out<=DATA;
led(1) <= DATA;

led(0) <= data_in;
led(2) <= cs_select;

sck <= clk_1Hz ;
C <= s_C;
cs <= cs_select;

end Behavioral;

Thanks for your help :)

Link to comment
Share on other sites

Hi Harimaya,

This project is unfortunately not trivial. The best example of use of the MRF24J40 that I know of is Microchip's MiWi Protocol. They have some demo projects for their MiWi Demo boards and Chipkits up on their site: http://www.microchip.com/pagehandler/en-us/technology/personalareanetworks/technology/home.html under MiWi Tools and "Click to Download MiWi Demo Source Code Here". Due to their MiWi licenses, I believe that we would be unable to distribute source code for an FPGA demo using MiWi, which would mean entirely rewriting the stack code (or for you to do the same, which again, would be quite difficult). If possible, I'd recommend you instead use a ChipKit board, since distribution of this sort of source appears to be within the license, and Microchip has demos which should require relatively minimal work to get running.

Thanks,

Arthur

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...