My problem:
I am trying to connect the CPU PIC18f252 with module RFM42B using hardware SPI. However, I have no response from the RF module.
1)
- I set the CPU clock 20MHz
- setup_spi (spi_master | spi_l_to_h | spi_clk_div_64)
- I set SDN at low level
- I set the SEL at low level
- spi_write (0x01)
- Result = spi_read ()
- I set a high-level SEL
I always get the result = 0
2)
- I set the CPU clock 20MHz
- setup_spi (spi_master | spi_h_tol | spi_clk_div_64)
- I set SDN at low level
- I set the SEL at low level
- Spi_write (0x01)
- Result = spi_read ()
- I set a high-level SEL
I always get the result = 0
When I set the level of SDN High - result = ff
Software SPI is working correctly - result always wynik = 06 is correct
Look on page 3. It shows the SPI timing. It shows that SCLK idles at
a low level and samples the data on the rising edge. This is SPI Mode 0.
You should add the following #define statements above main() and edit
the setup_spi() statement so it uses Mode 0. Example:
This line will not produce the SPI clock, so it will not clock in the new data.
You need to add a 0x00 parameter to tell it to make the SCLK signal.
Example:
Code:
result = spi_read(0);
madmax
Joined: 15 Nov 2011 Posts: 2
Posted: Wed Nov 16, 2011 12:33 pm
Thank you for help. Communication works. I did not know spi_read does not generate the clock signal . _________________ Piotr
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum