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 CCS Technical Support

PCF2127 clock IC RAM write/read

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



Joined: 12 Apr 2015
Posts: 6
Location: New Zealand

View user's profile Send private message

PCF2127 clock IC RAM write/read
PostPosted: Sun Apr 12, 2015 3:20 pm     Reply with quote

I am trying to write & read to the RAM in the PCF2127 clock IC
using SPI.
The data sheet only shows the IIC sequence.
I can wr/rd the clock date & time and the configuration regs OK, so my hardware is good.

Has anyone done this?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 4:00 pm     Reply with quote

It's shown in Figure 38b on page 64 of the pcf2127 data sheet.
www.nxp.com/documents/data_sheet/PCF2127.pdf
The diagrams on the lower 2/3rd's of the page show how to do it.
Compare the code below to the diagrams.
Code:

void write_pcf2127_ram(int16 addr, int8 data)
{
output_low(PCF2127_CS);
spi_xfer(0x3a);
spi_xfer(addr > 8);  // addr msb
spi_xfer(addr);      // addr lsb 
output_high(PCF2127_CS);

output_low(PCF2127_CS);
spi_xfer(0x3c);
spi_xfer(data);
output_high(PCF2127_CS);
}

The code above is for writing one byte only. The diagrams show how
to write multiple bytes. In that case you would supply a pointer to an
array. The function above would have to be re-written somewhat.

The reading of RAM is shown on page 65. You can write that one.
donW



Joined: 12 Apr 2015
Posts: 6
Location: New Zealand

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 4:19 pm     Reply with quote

thanks for quick reply!
my 'write byte' is in the same sequence as you show.
Can you show me the 'read a byte' code?
The datsheet IIC routine is confusing: it shows to setup the read adress,
then a write to reg 1D ? then data read....
donW



Joined: 12 Apr 2015
Posts: 6
Location: New Zealand

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 4:43 pm     Reply with quote

your datasheet is newer than mine.. which does not have the SPI examples
I am doing write & read as per your datasheet, but still can only get 00's back from the RAM...
donW



Joined: 12 Apr 2015
Posts: 6
Location: New Zealand

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 5:15 pm     Reply with quote

Found my problem ! my write routine was using the wrong port for /CS pin..
ram now working...
Thanks for the newer version of datasheet..
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