(SPI) can a master know its slave's register address?

Discussion of the PSoC Designer integrated development environment for PSoC1 devices.

Moderators: ericb, dcooper, jonp, dpfunston

(SPI) can a master know its slave's register address?

Postby jsyang » Sat Jul 27, 2013 10:32 am

I think it's a very silly, silly question. Well, but i'm stuck in a very silly situation, so I need help.

I am trying to make an mcu CY7C60445 to communicate with a RF chip CYRF8935 through SPI. I've looked into some example codes and datasheets, but there's still a missing link.

CYRF8935 has about 50 registers. 32 of them are SPI registers. Each register values play important roles in RF communication, like setting up its frequency channel, en/disabling RX/TX mode, packet length and so on.

But as far as my knowledge goes, MCU which is a master, has SPIM_SendTxData(0x**); It only sends data to the slave, without even knowing it exists.
Each register of CYRF(slave) is 16 bits in size. And in the datasheet, there are recommended values for each registers, expressed in hex. Fine. The master should assign its slave the right register values.

My missing link is, how should the master send commands to tell the slave to which register address the data should be stored?
(by the way, CYRF8935 is not programmable. All the programming has to be done within the mcu(master) alone)

Is there a code or a function that indicates the slave's register address? or should the address be included in the transmitted data from the master?

How should I write a c code then?

Thanks in advance.

JS.
jsyang
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Thu Jul 25, 2013 8:52 am

Re: (SPI) can a master know its slave's register address?

Postby danadak » Sun Jul 28, 2013 4:14 am

Take a look at this basic video/ap note, very insightful into slave
addressing, and general SPI operation.

http://www.cypress.com/?rID=34609

If you need a non HW addressable protocol, consider I2C, albeit its
inherently a slower protocol. Or addressable SPI mode and create a
slave polling mechanism to determine what slaves and how many are
out there.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: (SPI) can a master know its slave's register address?

Postby jsyang » Mon Jul 29, 2013 12:46 am

I already saw that video, and the datasheet.

My problem is that I can only program the master. Slave (RF TxRx) is not programmable.

So, in my c code, if I want to store 0x0000 into Register 7 of the slave, then it would be easy enough to write, Reg[7]=0x0000; and this is what most of the example codes go.

But since the slave is not programmable, I don't think the registers can be declared in my c code( or CAN I ?).
All I can do within the master's reach is to use SPIM_SendTxData('data'); - send a chunk of data out into the slave.
But somehow slave has to know to which register this data belongs to. How can this be done?
Can SPIS_ReadRxData() be used? (since the MCU I'm programming only contains the master, I say no).

So far I can think of 2 solutions-
either (somehow) declare 'Reg' in the c code, and simply write Reg[7]=0xdata
or the data I send is composed of 2 parts (address - data) so that when I send data, the address is attached along with it.

But I've never heard that instances outside the chip can be declared, or that SPI data consist of address.

can anybody give me a hand.. :(
jsyang
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Thu Jul 25, 2013 8:52 am

Re: (SPI) can a master know its slave's register address?

Postby bobmarlowe » Mon Jul 29, 2013 1:44 am

In the datasheet of your CYRF8935 starting at page 31 is exactly defined how the internal registers are accessed:
Datashee says:
SPI Transaction Formats and Timing
SPI read and write data is always in multiples of bytes. The first byte (MSB) consists of the R/W direction bit, followed by a 7-bit register
address. Following this byte, there are one or more data bytes.

Datasheet is here

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: (SPI) can a master know its slave's register address?

Postby jsyang » Mon Jul 29, 2013 1:53 am

Gosh, can't believe I missed that paragraph! That was so dumb of me... :cry:

Thank you so much. I got a lesson that there's always a solution in the datasheet (I was so hasty googling!)

Best regards,

JS.
jsyang
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Thu Jul 25, 2013 8:52 am

Re: (SPI) can a master know its slave's register address?

Postby bobmarlowe » Mon Jul 29, 2013 4:34 am

Well, to your excusion: Imho the organization of the datasheet could be done better. When talking about "Writing into a register" it would be much better to have told at this very place already what a register is and how it is accessed.

Keep your head up :mrgreen:
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany


Return to “%s” PSoC Designer (PSoC1 IDE)

Who is online

Users browsing this forum: No registered users and 1 guest

cron