PSCO4 stdUART MCU <--> PIC MCU not working, (Solved)

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

cross mob
Anonymous
Not applicable

Please help me!

I've tried to do this on my own and spent >10 hours trying to get this idea to work, searched for sample software, read the SCB specsheet, searched the net!

I have a CY8KIT-042  eval board(mcu CY8C4245) to use to receive/send binary array of bytes to a PIC MCU, both directly connected Tx<-->RX.  configured 115200, 8,n,1   on both mcu's.

The cmd/data sent/received is always a fixed-size array of binary bytes .

The PIC is always the master.

PIC initiates a chat by sending 41 bytes binary.  (contained in an array: unsigned char Tx[41] ) to be received and placed into a unsigned char Rx[41] array on the CY8Kit.

The Cypress then sets a flag that a new byte/data pac of 41 bytes has been received and processes the received 41-byte buffer of cmds and data.

.

The Cy then should Tx back to the Cy8Kit the updated data in its  unsigned char Tx[41]

I have the PIC Xmit functioning perfectly Tx'ing the 40-byte array once a second (always same 40 test bytes). I have verified this on my scope.

I can't seem to get any received data into the CY8KIT. I haven't yet begun to write the code sending data back to the PIC.

Here is my HW info and code on the PSOC side of this game:

I configured the std UART SCB:      baud 115200,N,8,1

            HW:                                          for  Tx and Rx

                                                        Tx output pin P0[5] Tx  ----->PIC Rx

                                                         Rx input pin  P0[4] Rx ------>PIC Tx     (using 3-in flying wires for both connections including connecting both Vss(Gnd) and VDD(5V)<

                                                         Rx input pin on Cy has 18k pullup to +5

Config of SCB UART                         UART    (alias UA)

                                                         Rx and TX

                                                         FIFO size:  41

                                                         12 x oversampling Rx

                                                          System Clock 24Mhz

                                                          Only one active Interrupt checked:   RX FIFO UNDERFLOW

My Cypress Code:

//before main()

unsigned char Tx[41],Rx[41],rbyt=0;

CY_ISR_PROTO (ISR_UART);

void ISR_UART()

{

    /* Returns the status/identity of which enabled RX interrupt source caused interrupt event */

    uint32 source = UA_GetRxInterruptSource();

    /* Checks for "RX FIFO AND not empty" interrupt */

    if(0ul != (UA_INTR_RX_NOT_EMPTY & source))

     {

        /* Get the character from terminal */

        Rx[rbyt] = UA_UartGetByte();

        rbyt++;   //Counts the number of bytes received

        if(rbyt>41)rbyt=0;

        /* Clear UART "RX FIFO not empty interrupt" */

        UA_ClearRxInterruptSource(UA_INTR_RX_NOT_EMPTY);

        UA_ClearPendingInt();

     }

   else

   ClearPendingInt();

}

int main(void)

{

CyGlobalIntEnable; /* Enable global interrupts. */

CySysWdtDisable(0);// Disable, WDT to do nothing on WDT timeout

rbyt=0;

UA_Start();

UA_EnableInt();

UA_SetCustomInterruptHandler(ISR_UART);

start:   //---------------------------------------------------------------

// code continues here displays the value of rbyt on the Cy  and is now always showing 0  (a multiple digit 7-Seg display.. works 100%)

  goto start;

}

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

Hi,

Since I don't have a PIC board, I used PC(and TeraTerm) to emulate a PIC.

I copied your source and added a debug command to print out the value(s) when rbyt hits 41.

I hope that I have not touched any other part(s).

And seeing the result (TeraTerm Log), your program seems to be working.

Then I would suggest you to check the hardware connection between

CY8CKIT-042 and your PIC.

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

#include "project.h"

#include <stdio.h>

char str[128] ; /* print buff */

//before main()

unsigned char Tx[41],Rx[41],rbyt=0;

CY_ISR_PROTO (ISR_UART);

void ISR_UART()

{

    /* Returns the status/identity of which enabled RX interrupt source caused interrupt event */

    uint32 source = UA_GetRxInterruptSource();

    /* Checks for "RX FIFO AND not empty" interrupt */

    if(0ul != (UA_INTR_RX_NOT_EMPTY & source))

    {

        /* Get the character from terminal */

        Rx[rbyt] = UA_UartGetByte();

        rbyt++;  //Counts the number of bytes received

        if(rbyt>41)rbyt=0;

        /* Clear UART "RX FIFO not empty interrupt" */

        UA_ClearRxInterruptSource(UA_INTR_RX_NOT_EMPTY);

        UA_ClearPendingInt();

    }

  else

      UA_ClearPendingInt() ; // was ClearPendingInt();

}

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    CySysWdtDisable(0);// Disable, WDT to do nothing on WDT timeout

    rbyt=0;

    UA_Start();

    UA_EnableInt();

    UA_SetCustomInterruptHandler(ISR_UART);

start:  //---------------------------------------------------------------

// code continues here displays the value of rbyt on the Cy

// and is now always showing 0  (a multiple digit 7-Seg display.. works 100%)

    if (rbyt == 41) {

        int i ;

        UA_UartPutString("\n") ;

        for (i = 0 ; i < rbyt ; i++) {

            sprintf(str, "%02X ", Rx) ;

            UA_UartPutString(str) ;

        }

        UA_UartPutString("\n") ;

        rbyt = 0 ;

    }

  goto start;

}

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

TeraTerm Log

I set local echo on, so my typing is shown as letters,

but when 41st letter hits, the debug command prints out them in Hex format.

uart_test_log.JPG

moto

View solution in original post

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

Hi,

Since I don't have a PIC board, I used PC(and TeraTerm) to emulate a PIC.

I copied your source and added a debug command to print out the value(s) when rbyt hits 41.

I hope that I have not touched any other part(s).

And seeing the result (TeraTerm Log), your program seems to be working.

Then I would suggest you to check the hardware connection between

CY8CKIT-042 and your PIC.

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

#include "project.h"

#include <stdio.h>

char str[128] ; /* print buff */

//before main()

unsigned char Tx[41],Rx[41],rbyt=0;

CY_ISR_PROTO (ISR_UART);

void ISR_UART()

{

    /* Returns the status/identity of which enabled RX interrupt source caused interrupt event */

    uint32 source = UA_GetRxInterruptSource();

    /* Checks for "RX FIFO AND not empty" interrupt */

    if(0ul != (UA_INTR_RX_NOT_EMPTY & source))

    {

        /* Get the character from terminal */

        Rx[rbyt] = UA_UartGetByte();

        rbyt++;  //Counts the number of bytes received

        if(rbyt>41)rbyt=0;

        /* Clear UART "RX FIFO not empty interrupt" */

        UA_ClearRxInterruptSource(UA_INTR_RX_NOT_EMPTY);

        UA_ClearPendingInt();

    }

  else

      UA_ClearPendingInt() ; // was ClearPendingInt();

}

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    CySysWdtDisable(0);// Disable, WDT to do nothing on WDT timeout

    rbyt=0;

    UA_Start();

    UA_EnableInt();

    UA_SetCustomInterruptHandler(ISR_UART);

start:  //---------------------------------------------------------------

// code continues here displays the value of rbyt on the Cy

// and is now always showing 0  (a multiple digit 7-Seg display.. works 100%)

    if (rbyt == 41) {

        int i ;

        UA_UartPutString("\n") ;

        for (i = 0 ; i < rbyt ; i++) {

            sprintf(str, "%02X ", Rx) ;

            UA_UartPutString(str) ;

        }

        UA_UartPutString("\n") ;

        rbyt = 0 ;

    }

  goto start;

}

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

TeraTerm Log

I set local echo on, so my typing is shown as letters,

but when 41st letter hits, the debug command prints out them in Hex format.

uart_test_log.JPG

moto

Anonymous
Not applicable

Thanks a Gigabyte!

I just again checked by Tx--Rx and (ooops!) I had mistakenly soldered the right wire in the left place. 

The whole problem boiled down to HW.  Tx-->Tx   Rx-->Rx