CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SPI error on Pic24fj128ga010 with RFM69 [Solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joseph20480



Joined: 21 Dec 2011
Posts: 42

View user's profile Send private message

SPI error on Pic24fj128ga010 with RFM69 [Solved]
PostPosted: Sun Mar 31, 2019 4:04 am     Reply with quote

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: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Mar 31, 2019 4:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Mar 31, 2019 8:14 am     Reply with quote

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 !
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group