Running hoperf on PSoC

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

cross mob
lock attach
Attachments are accessible only for community members.
BUTA_1301626
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

I want to use HopeRF's RFM22B transceiver module in psoc. Can you help me if you have been running with psoc before?

0 Likes
1 Solution

Oh. Alright. Then, refer to the Code example here: https://www.cypress.com/documentation/code-examples/ce95377-spi-master-and-slave-psoc-35lp . I think you can use the same configurations as stated in the Code Example.

-Regards,

Sanjeev AG

View solution in original post

0 Likes
9 Replies
SanjeevG_16
Employee
Employee
10 likes received 10 likes given 5 likes given

Hi,

As you figured out from the datasheet, the communication with the module is through SPI. Now PSoC is the SPI master and the module is the SPI slave. All you need to do is configure the SPI master.

The configuration structure for SPI master is:

1)  SPI mode : Master

2)  submode: Motorola

3) SCLK mode: CPOL = 0; CPHA = 0

From the timing diagram of the datasheet, the data transfer happens on the Rising edge of the clock so the CPOL = 0, CPHA = 0.

4) Oversample: 6

It is really your combination to select Oversample and Data Rate. The Clock frequency is given by Data Rate x Oversample. From the datasheet, it is given that the maximum Clock frequency should be around 10MHz maximum. So I figured if 3MHz clock frequency with 500Kbps and Oversample: 6

5) rxDataWidth: 8

6) txDataWidth: 8

The data width specified from the timing diagram was 8 bits for tx and rxBuffer. So give these settings. For the code, try this code example:

https://www.cypress.com/documentation/code-examples/ce221120-psoc-6-mcu-spi-master

Do let me know if that works.

-Thanks

0 Likes

I want to use psoc 5lp. "psoc cy8c059 kit"

0 Likes

Oh. Alright. Then, refer to the Code example here: https://www.cypress.com/documentation/code-examples/ce95377-spi-master-and-slave-psoc-35lp . I think you can use the same configurations as stated in the Code Example.

-Regards,

Sanjeev AG

0 Likes
lock attach
Attachments are accessible only for community members.
BUTA_1301626
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hi Sanjeev AG;

How do I run the enclosed arduino project for psoc?

0 Likes

You need to modify the driver files "HopeDuino_22b.h/c" files to use PSoC Creator specific component APIs. For example, the spi_read function should be replaced by SPIM_ReadRxData and so on. Please refer to the code example provided previously to understand more about how SPI communication works in PSoC devices and how to implement it.

Write the code in the .ino file in the main.c file.

Regards,
Dheeraj

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

Hi Dheeraj;

I tried to implement the program to the PSoC device.

I get some errors during build.

--------------- Build Failed: 08/16/2019 16:13:38 ---------------

--------------- Build Started: 08/16/2019 16:13:58 Project: HOPERF_TX, Configuration: ARM GCC 5.4-2016-q2-update Debug ---------------

The code generation step is up to date.

arm-none-eabi-gcc.exe -mcpu=cortex-m3 -mthumb -I. -IGenerated_Source\PSoC5 -Wa,-alh=.\ARM_GCC_541\Debug/main.lst -g -ffunction-sections -ffat-lto-objects -Os -c main.c -o .\ARM_GCC_541\Debug\main.o

main.c: In function 'main':

main.c:35:33: warning: implicit declaration of function 'millis' [-Wimplicit-function-declaration]

   unsigned long currentMillis = millis();

                                 ^

main.c:47:20: warning: passing argument 1 of 'LCD_PrintString' makes pointer from integer without a cast [-Wint-conversion]

    LCD_PrintString(cnt_tx++);

                    ^

In file included from Generated_Source\PSoC5/project.h:31:0,

                 from main.c:6:

Generated_Source\PSoC5/LCD.h:60:6: note: expected 'const char8 * {aka const char *}' but argument is of type 'unsigned int'

void LCD_PrintString(char8 const string[]) ;

      ^

main.c:56:22: warning: passing argument 1 of 'LCD_PrintString' makes pointer from integer without a cast [-Wint-conversion]

      LCD_PrintString(cnt++);

                      ^

In file included from Generated_Source\PSoC5/project.h:31:0,

                 from main.c:6:

Generated_Source\PSoC5/LCD.h:60:6: note: expected 'const char8 * {aka const char *}' but argument is of type 'unsigned int'

void LCD_PrintString(char8 const string[]) ;

      ^

main.c:59:6: warning: implicit declaration of function 'LCD_PrintStringN' [-Wimplicit-function-declaration]

      LCD_PrintStringN(rev_array, num);

      ^

main.c: In function 'print_all_regs':

main.c:69:9: error: too many arguments to function 'SPIM_ReadRxData'

   ret = SPIM_ReadRxData(i);

         ^

In file included from Generated_Source\PSoC5/project.h:29:0,

                 from main.c:6:

Generated_Source\PSoC5/SPIM.h:96:7: note: declared here

uint8 SPIM_ReadRxData(void) \

       ^

main.c:72:2: warning: implicit declaration of function 'LCD_PrintStringn' [-Wimplicit-function-declaration]

  LCD_PrintStringn(ret, HEX);

  ^

main.c: At top level:

main.c:87:1: error: expected identifier or '(' before 'for'

for(;;)    {

^

main.c:87:7: error: expected identifier or '(' before ')' token

for(;;)    {

       ^

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

--------------- Build Failed: 08/16/2019 16:13:58 ---------------

0 Likes

Arduino code won't work directly in PSoC Creator. Make modifications to use PSoC Creator components and corresponding APIs. Otherwise you will keep seeing these errors.

Regards,

Dheeraj

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

I changed the ardunino codes for psoc.

I built it.but I'm examining it with a logic analyzer. no sign.

I can't find where I made a mistake. can you help me?

Thanks and regards

0 Likes

You have changed only some of the things. Arduino specific codes like "void setup" and "void loop" won't work here. Also, in the driver files "HopeDuino_22b.h/c" I do not see any changes done.

For example, in the function "rec_message(u8* p_data)", all the code needs to be modified to use PSoC Creator component APIs to read RX data once the RX interrupt is triggered. The API "SPIM_ReadRxData" hasn't been implemented anywhere inside it.

Please refer to this code example for better understanding of how to implement SPI and how to read data: https://www.cypress.com/documentation/code-examples/ce95377-spi-master-and-slave-psoc-35lp

Regards,

Dheeraj

0 Likes