Which psoc more convenient ==>PSOC6 or 5 or 3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BUTA_1301626
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

I have a project to use SPI communication.I need to change the register values of the module I will communicate with.

adress==>6F    (function ==>TX Data Rate 0)      (txdr[7])     (txdr[6])     (txdr[5])     (txdr[4])     (txdr[3])     (txdr[2])     (txdr[1])     (txdr[0])       ======>3Dh

                                                                                  0                   0             1                1              1                 1                 0                1

I want to upload 3dH to 6F adress.

PSOC3==> 8051

PSOC35  and PSoC6 ==> ARM cortex

Since PSOC3 is 8051, I should prefer my PSOC3.

0 Likes
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi BUTA_1301626

I believe this is a continuation to this thread.

The SPI component versions are same in both 5LP and 3, therefore, the functionality would be silimar. We recommend using the new devices for better features.

Thanks and regards

Hari

View solution in original post

0 Likes
20 Replies
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi BUTA_1301626

I believe this is a continuation to this thread.

The SPI component versions are same in both 5LP and 3, therefore, the functionality would be silimar. We recommend using the new devices for better features.

Thanks and regards

Hari

0 Likes

Hi Hari;

Yes the continuation of the subject. but nobody helped.

I still don't know how to upload 3dH to 6F adress.

for example ==> For Arduino==> spi_write(0x6F, 0x3D);

Can not perform the same process psoc?

adress==>6F    (function ==>TX Data Rate 0)      (txdr[7])     (txdr[6])     (txdr[5])     (txdr[4])     (txdr[3])     (txdr[2])     (txdr[1])     (txdr[0])       ======>3Dh

                                                                                  0                   0             1                1              1                 1                 0                1

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi BUTA_1301626

In arduino, the library directly supports this functionality, but we dont have a similar library for PSoC. You can port the library to PSoC creator and use the functions normally since both are embedded C. There are only minor changes with component APIs and this must be changed for PSoC.

Thanks and regards

Hari

0 Likes

Hi Hari;

Do you know how to make a change?

spi_write(0x6F, 0x3D); ==>I know this command does not work in psoc. I know this is an arduino command.

I have been dealing with this process for a long time and I could not.

this is the purpose of my forum writing. I can't do I want to know how it's done or I want to know where I'm doing it wrong.

Is there anyone who can help me with this?

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi BUTA_1301626

Can you share the latest library file that can be used to interface with the sensor?

Thanks and regards

Hari

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Hari;

I added the arduino files.

I added the file I edited for PSOC.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello BUTA_1301626

Going through the Arduino files, the implementation is based on pin toggles only. So, you can import these files and change the Arduino commands to PSoC commands such as digitalWrite must be replaced with Pin_Write. You can define 4 pins for MOSI, MISO, SCLK and SS.

Referring to the datasheet of, the addressing is straightforward. It is one bit of R/W followed by 7bits of address and 8 bits of data. So, you can also try to increase the data bits of the SPI component.

pastedImage_0.png

You can then send a 16bit data by concatenating R/W, Address and Data.

This can be done by,

uint8 rw = 0;

uint8 addr = 0x6F;

uint8 data = 0x3D;

uint16 spidata = 0x00;

spidata = (uint16) (rw<<15)| addr<<8 | data;

This will concatenate the data its properly and this can be transmitted using SPIM_WriteTxData. Please note that the maximum speed possible in the transceiver module is 10MHz so the speed has to be lower than this.

Since I don't have this controller at my end, I cannot try out the project to see if it is working..

Thanks and regards

Hari

0 Likes

Hi Hari;

which code would be more accurate?

SPIM_WriteTxData(0x6F3D);

                  or

uint8 buf[2]={0x6F, 0x3D};

SPIM_PutArray(buf, byteCount);

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi BUTA_1301626

Since I don't have the transceiver at my end, I cannot test this and tell you which is more accurate. Please try both methods to see their functionality.

Based on reading the device datasheet however, I feel that

SPIM_WriteTxData(0x6F3D);

would be a better implementation as it agrees directly with the frame format.

If you have any queries after the implementation, please feel free to post it in this thread.

Thanks and regards

Hari

Hi Hari;

adress ==>0x07 data==>RF22_PWRSTATE_READY   ==> data is the variable RF22_PWRSTATE_READY.

SPIM_WriteTxData(0x07??);  how can i write this operation.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi BUTA_1301626

You can follow a similar explanation as the previous response, by adding the data into a 16bit variable and transmitting it.

That is, in the case that is mentioned, assuming we have to write RF22_PWRSTATE_READY in address 0x07, the code would be

uint8 rw = 0;

uint8 addr = 0x07;

uint8 data = RF22_PWRSTATE_READY ; //where RF22_PWRSTATE_READY  variable holds the data

uint16 spidata = 0x00;

spidata = (uint16) (rw<<15)| addr<<8 | data;

SPIM_WriteTxData (spidata);

Please try this out and let us know if it works. You can also probe the lines to see if the data is actually transmitted according to the conditions that you require. You can compare the waveform with that obtained from some other controllers for reference.

Thanks and regards

Harigovind

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I'm just curious but in the data sheet

rw =1 for write and rw = 0 for read (page 15)

So how about writing a simple function

and reuse it for different address/data?

===================

void spi_write(uint8_t address, uint8_t data)

{

   uint16_t buf ;

   buf = 0x8000 | (address << 😎 | data ;

   SPIM_WriteTxData(buf) ;

}

===================

Note: if name spi_write() conflicts, use my_spi_write() or something like that.

moto

lock attach
Attachments are accessible only for community members.

I compiled the program without error. but the rf module still did not work.I have a few questions about this.

1. I set the pins as input and output. Are the drive mode and initial drive state settings very important?

input ==> drive mode ==> high impedance digital initial drive state ==> low

output ==> drive mode ==> strong drive initial drive state ==> low                                    is it true?

MOSI, OUTPUT

MISO, INPUT

SCK, OUTPUT

RESET, OUTPUT

nIRQ0, INPUT

nCS, OUTPUT

TXEN, OUTPUT

RXEN, OUTPUT

2. I used the clock 75khz. This is clock digital. Can I set analog? Is it a problem if I set it?

3.Can I set the voltage to 3.3V to operate the module with the kit? I tried to do the system settings but did not.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello BUTA_1301626

In your code, you have combined the two suggestions mentioned in my previous response. In PSoC you are not supposed to use software APIs (such as Pin_Write) when the pin is connected to a hardware block. That is, in your design, SCK, nCS and MOSI are connected to the SPI hardware block and you are trying to change it in firmware by writing CSK_Write(0) etc. This is not allowed

In the current implementation, remove the SPI block and see if the code works.

Also, probe the SPI lines to make sure that there is activity on the SPI bus.

Thanks and regards

Hari

0 Likes

Hi Hari;

I see that I get the outputs I want with the help of logic analyzer.but the module works with arduino. but does not work with psoc.,

Can I make a mistake about the input or output settings?(strong drive resistive pull up/down,high impedance digital) which one is true?

3.3v required for the module. Can I get 3.3v with the help of psoc (kitprog59)?

rfm22b1.JPGrfm22b2.JPG

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello BUTA_1301626

Please try using resistive pull-up configuration for MISO line to see if there is any activity on the line (assuming you are using pins and going with the firmware implementation).

The MOSI line is sending data and need not be altered.

Thanks and regards

Hari

0 Likes

Hi Hari;

I made MISO resistive pull-ups. but nothing changed that still does not work.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello BUTA_1301626

Can you please send the logic data using both arduino and PSoC for our comparison? As you can observe from the waveform, the host (PSoC) is working and the MOSI line is actually sending data.

Also, please make sure that the data being sent is correct and the intended data since the controller is not responding.

Please check the speed of transmission as well.

Best regards

Hari

0 Likes

The first two figures for the logic analyzer are for the arduino.

arduino.JPGFigure 1aruino2.JPGFigure 2

The other two shapes for the logic analyzer (Figures 3 and 4) are for psoc.

PSOC2.JPGFigure 3PSOC3.JPGFigure 4

As I said before, the logic analyzer results of the two systems are the same.

There's another simple problem, but I can't find it.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello BUTA_1301626

As I see, even in the waveform shared for arduino, the RF device does not seem to be sending any data (the MISO line is always HIGH, FF). PSoC is also detecting something similar only, only difference being the MISO line is pulled LOW. You can either set the pin mode as resistive pull-up or connect an external pull-up resistor to observe similar result.

Please check the clock speed of both PSoC and Arduino to verify if the data rate is correct. You can do this from the logic data itself. Please measure the frequecy of SPI_CLOCK line.

Thanks and regards

Hari

0 Likes