Adapt from a Psoc4 to a Psoc5 LP097

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

cross mob
pavic_2246186
Level 1
Level 1

Good afternoon .. Someone who is clear about the handling of Psoc, could do me the enormous favor of adapting this program that I attached below so that it works in a PSOC 5 LP097 .. Thank you very much

The file that I want to adapt is in the following link and it is called "Download DMX Receiver3.zip​"

https://www.cypress.com/comment/220886

Thank you

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

For my study of using PSoC 5LP, I tried one.

As Hima-san, said the porting itself was pretty easy,

but to let the Receiver detect the "Break"

and to let the Master send "Break" were not.

According to the Datasheet of UART, it is said to be 11~14bit long, but in the UART.h the default is (13u).

So I made the length of the break to be 13bit long but the Receiver did not detect it,

after a half day of struggle, I found that the secret was in the "Config Dialog" of UART,

but in the default it's not shown, I had to scroll down the dialog

to finally find the "Advanced features > Break signal bits" and for the default it is set to "none".

000-Receiver_UART_1.JPG

002-Receiver_UART_3.JPG

Meantime somehow, I could not make UART_SendBreak() work, so I had to use MUX and Control_Reg to tweak TX.

UART_SendBreak() itself was actually generating "break" but somehow it was not detected by the Slave.

Master Schematic

004-Master_sch.JPG

Slave Schematic

003-Receiver_sch.JPG

About the boards, I used CY8CKIT-050 for the controller and CY8CKIT-059 for the receiver.

IMG_3375.JPG

And I used the RGB LED of another MCU board we had.

It seems to be working...

moto

View solution in original post

0 Likes
7 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

I see that the project has UART and PWM components only. The porting will be straight forward. If you face any specific issues with porting please let us know.

If you want to know more about implementation with DMA please have a look at this post

UART-DMA and Break

Thanks,

Hima

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

For my study of using PSoC 5LP, I tried one.

As Hima-san, said the porting itself was pretty easy,

but to let the Receiver detect the "Break"

and to let the Master send "Break" were not.

According to the Datasheet of UART, it is said to be 11~14bit long, but in the UART.h the default is (13u).

So I made the length of the break to be 13bit long but the Receiver did not detect it,

after a half day of struggle, I found that the secret was in the "Config Dialog" of UART,

but in the default it's not shown, I had to scroll down the dialog

to finally find the "Advanced features > Break signal bits" and for the default it is set to "none".

000-Receiver_UART_1.JPG

002-Receiver_UART_3.JPG

Meantime somehow, I could not make UART_SendBreak() work, so I had to use MUX and Control_Reg to tweak TX.

UART_SendBreak() itself was actually generating "break" but somehow it was not detected by the Slave.

Master Schematic

004-Master_sch.JPG

Slave Schematic

003-Receiver_sch.JPG

About the boards, I used CY8CKIT-050 for the controller and CY8CKIT-059 for the receiver.

IMG_3375.JPG

And I used the RGB LED of another MCU board we had.

It seems to be working...

moto

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

Thanks for your help Motoo Tanaka.

I did exactly what you tell me ... and I can not make my DMX receiver work. I am using a USB-DMX converter like the following link to generate the DMX signal from a PC. (https://articulo.mercadolibre.com.ar/MLA-673668334-interfaz-interface-usb-dmx-512-opto-aislada-2-sal...)

To the program that you passed me I added an lcd to be able to verify the changes in the RGB outputs; and they are not modified by changing the DMX value from the PC (freestyler software).

In which DMX channel would this program work? How do you think I could make it work in this program with that converter? Thank you..

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

Dear Pablo-san,

> I did exactly what you tell me ...

I wonder what I told you...

Anyway, have you read my previous posting?

I also had very hard time to make the slave work, because UART component of PSoC 5LP does not seem to accept "Break" signal when its length is not exactly the same with the length specified in the configuration.

Even the "Break" signal generated by PSoC 5LP (CY8CKIT-050) could not be detected. (sigh)

So I HACKED THROUGH by creating the exact "Break" signal which the UART of slave 5LP's UART can detect.

To check if this is the problem you are facing, please use PSoC Creator and debug the slave program.

(1) First place a break point at line 25

    status = UART_ReadRxStatus();

Then run the program and use the PC-DMX tool you have to communicate with the slave.

If the program stops at the break point, at least the UART is receiving the serial signal OK.

If it does not stop at the break point, please check and make sure that hardware connection is OK.

(2) Remove the break point above, and place a break point at line 32

        isBreak = TRUE;

This break point is hit only when "Break" signal is detected.

Then run the program and use the PC-DMX tool you have to communicate with the slave.

If the program stops at the break point, "Break" signal is detected OK.

(Note: I'm guessing this does not take place)

If it does not stop at the break point, we must figure out how we can work out this problem.

(Note: Probably it's better creating a new question thread about how to make the UART detect usual "Break" signal)

Best Regards,

13-Feb-2019

Motoo Tanaka

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Pablo-san,

Since I did not like the way the original program(s) were written,

I tried clean them up today.

After cleaning up and added another usual UART for logging,

slave program is now capable of receiving longer Break signal.

I tried up to more than 100bit long Break but the slave could receive the Break.

To be honest, I have no idea why previous version did not accept Break other than an exact length.

So may be this version can work with your Controller.

And in the logging window the address is written as 0.

DMX_Slave_190215.JPG

Best Regards,

15-Feb-2019

Motoo Tanaka

0 Likes

Thanks again for your help Motoo Tanaka

Try the project of the last receiver that you sent me .. and when I open the tera term only this appears to me (I set it to a speed of 115200 at the tera term)

tera term.jpg

Then try to do what you said in the previous post to put the brakpoint on line 29

status = UART_ReadRxStatus ();

and the program if it stops at that brakpoint

When I do it for line 36

  isBreak = TRUE;

The program is also stopped at that point.

However, when I put a breakpoint on line 123,

  sprintf (str, "Address:% 3d Network:% 3d, Green:% 3d, Blue:% 3d \ n",

the program does not stop ..

According to what I saw ... it seems to me that the program is not entering the next if

if ((prev_r! = red)

How could I solve this?

Again many thanks Motoo Tanaka ...

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Pablo-san,

Today I played with this code again thanks for the weekend 😉

First of all, as the author of the original program mentioned in

https://www.cypress.com/comment/220886

the original program was a very simple experiment.

I would recommend you to read the specification if you are serious.

E1.11, USITT DMX512-A" or "ANSI E1.11-2004

https://opendmx.net/index.php/DMX512-A

Having said (written) that even to make this little code work was not easy,

since the data is sent almost a burst manner.

So attached is my trial and by no mean "final" nor "guaranteed" (you are warned)

The value "address" in the original code was really "start code" and when the startcode == 0,

there is not address scheme and the programmer or system must know the location of each data in the DMX stream.

The original author decided to have red in the first byte, green, blue, and white subsequently.

So I modified the ISR

[ from ]

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

CY_ISR(InterruptHandler)

{

    int status = 0;

 

    // Clear status

    status = UART_ReadRxStatus();

    // Clear any data

    UART_ClearRxBuffer();

 

    // Check for break

    if((status & UART_RX_STS_BREAK) != 0)

    {

        isBreak = TRUE;

    }

    int i = 0;

    int value = 0;

 

    //Receive data

    if(isBreak)

    {

        for (i = 0; i < 5; i++)

    {

            // Wait for data

    while (!(UART_ReadRxStatus() & UART_RX_STS_FIFO_NOTEMPTY));

            // Read Data

    value = UART_ReadRxData();

            // if the first one is not zero (first in value string should always be 0), wait longer

            if(i == 0 && value != 0){break;}

            // Put data in buffer

            DMXbuffer = value;

            // Clear status

            status = UART_ReadRxStatus();

    }

     

        i = 0;

    }

         

    // Reset Break

    isBreak = FALSE;

 

}

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

[ to ]

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

CY_ISR(dmx_rx_isr)

{

    int rx_status = 0;

 

    // Clear status

    rx_status = DMX_ReadRxStatus();

 

    if (rx_status & DMX_RX_STS_BREAK) {

        DMX_ClearRxBuffer() ;

        dmx_index = 0 ;

        dmx_status = ST_RECEIVING ;

    }

 

    if ((dmx_status == ST_RECEIVING)&&(DMX_ReadRxStatus() & DMX_RX_STS_FIFO_NOTEMPTY)) {

        dmx_buf[dmx_index++] = DMX_GetByte() ;

        if (dmx_index >= DMX_MY_CH_SIZE) { /* we got all we need, ignore the rest */

            data_received = TRUE ;

            dmx_status = ST_WAIT_FOR_BREAK ;

        }

    }

    DMX_RX_INT_ClearPending() ;

}

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

The TeraTerm screen shot looks like

000-TeraTerm-log.JPG

The upper half is quite usual if you are using CY8CKIT-059 and using UART via the USB connection.

To make the appearance slightly better, I added a new line before printing "DMX Slave Test"

And although usually I use LF for EOL as I am a Unix Background Guy, to compatible with Dozzers (Winel Users), I changed EOL of this program to CR+LF.

You could set TeraTerm's Terminal setup > New-line > Receive = AUTO.

001-TeraTerm-Terminal-setup.JPG

I hope this version works (slightly) better than the previous one.

Best Regards,

17-Feb-2019

Motoo Tanaka

0 Likes