View previous topic :: View next topic |
Author |
Message |
joseph20480
Joined: 21 Dec 2011 Posts: 42
|
SPI error on Pic24fj128ga010 with RFM69 [Solved] |
Posted: Sun Mar 31, 2019 4:04 am |
|
|
Dear forum,
I'm back with a new question.
I'm working to write a code for a project. I use a DevBoard Microchip Explorer16 with a PIM 24FJ128GA010.
Connected on board, a RFM69 module.
I have some troubles with the written mode. I'm able to read all registers perfectly (Compared with default value) But i can not write inside....
Do you have an idea ?
Please see my code... simple but with troubles:
Code: |
#use spi(SPI1,MASTER, BITS=8, MSB_FIRST)
#define pin_reset pin_d6
#define pin_select pin_e8
void rfm69_reset(void);
unsigned int8 rfm69_read8(unsigned int8);
void rfm69_write8(unsigned int8,unsigned int8);
//------------------------------------------------------------------------
void rfm69_write8(unsigned int8 addr,unsigned int8 data)
{
output_low(pin_select);
spi_write(addr | 0x80);
spi_write(data);
delay_us(25);
output_high(pin_select);
}
//----------------------------------------------------------------------
unsigned int8 rfm69_read8(unsigned int8 addr)
{
unsigned int8 valeur;
output_low(pin_select);
spi_write(addr);
valeur=spi_read(0);
delay_us(100);
output_high(pin_select);
return valeur;
}
//--------------------------------------------------------------------
void rfm69_reset(void)
{
delay_ms(10);
output_high(pin_reset);
delay_ms(1);
input(pin_reset);
delay_ms(10);
setup_spi(SPI_MASTER | SPI_SCK_IDLE_LOW | SPI_XMIT_L_TO_H | SPI_CLK_DIV_256);
while (rfm69_read8(0x01)!=0x04)
{
delay_ms(10);
}
output_high(pin_a0);
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sun Mar 31, 2019 4:58 am |
|
|
Please post a link to the datasheet for the RFM69 module you're using. You've got 'extra stuff' in what I'd think should be simple 'read and writes'. That may be causing problems....
A 'module' has parts other than the basic 'chip', so the datasheet should explain proper setup, config, operation.
Jay |
|
|
joseph20480
Joined: 21 Dec 2011 Posts: 42
|
|
Posted: Sun Mar 31, 2019 8:14 am |
|
|
temtronic wrote: | Please post a link to the datasheet for the RFM69 module you're using. You've got 'extra stuff' in what I'd think should be simple 'read and writes'. That may be causing problems....
A 'module' has parts other than the basic 'chip', so the datasheet should explain proper setup, config, operation.
Jay |
Ok, no problem... Dont' forget to use the correct power supply on your devboard and not only the power from programmer (PicKit3). On board there is some volatge translator who need 5v...
CLOSE ! |
|
|
|