cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

KyTr_1955226
Valued Contributor

Hey all,

I've got a project in the works that uses 3 UARTs.  I manage to fit in the 3 required, but I want to add a 4th for debugging purposes if possible.  This should be no problem, as I appear to have adequate UDB resources for a half-duplex UART according to the UART component datasheet:

KyTr_1955226_0-1618329089280.png

KyTr_1955226_1-1618329144785.png

However when I try to build, I'm running out of UDBs during placement.  Looks like running out of macrocells?  I'm curious as to why this is?  Something to do with how macrocells get allocated maybe?

I'm using PSoC Creator 4.3, the PSoC5LP part is a CY8C5667AXI-LP040.  I've attached the report file to this post.  DBG_UART is the component name for the half-duplex I am trying to add.  I had to put it in a .zip because apparently I can't upload .rpt or .txt files.

Appreciate any thoughts,

Thanks!

0 Likes
1 Solution
RodolfoGL
Employee

Hi all,

It is actually impossible to use 100% of the Macrocells or Pterms. Due to routing restrictions, you might not be able to use all the inputs/outputs of the PLDs. Said that, if you reach around 85~90% of a Macrocells or Pterms, the placer might not be able to fit your design.

View solution in original post

8 Replies
BiBi_1928986
Valued Contributor

Hello KyTr.

Although KIT-059 uses a different 5LP vs your project, there was a discussion about using 4 UARTs with KIT-059.  KIT-059 has 24 UDB's just like 5667.  Maybe some of this information will help.
https://community.cypress.com/t5/PSoC-5-3-1-MCU/uart-in-psoc5lp-cy8ckit-059/m-p/159490#198388

Some other suggestions:
Use USBUART.
Use software UART.
Use built-in 5LP I2C with KITprog I2C Bridge.  Yeah, it's a bit tricky/limited, but I used it in a pinch for debugging when all UDB resources were used up.

Good luck with your project.

0 Likes
KyTr_1955226
Valued Contributor

Hi BiBi,

Not a whole lot to go on in that linked thread to address the question about UDB resources, unfortunately. 

If I had no other components or digital design work I'm sure I could fit 4 UARTs without much trouble.  The software UART will get the job done at least for some basic info printed to my terminal.  Using the debugger tool I2C bridge is an interesting idea though.  I'll file that away for later, I can imagine it being useful at some point down the line.

This project is already using the USBFS component as a HID device but I'm really more interested in why I'm unable to use a UDB UART, when according to the resource meter, I should have the resources to do so.

I'm guessing it has something to do with how UDB resources are allocated?  Maybe something think a UART requires "contiguous" resources that it can't place between my other USB components?

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

Just like what BiBi-san has already suggested, I would suggest to consider software UART.

As you wrote that you need it for a debugging purpose,

hoping that you can put up with 9600 baud, 

I tried a simple software UART TX

using CY8CKIT-059. (Hopefully it will work with your device.)

 

schematic

002-schematic.JPG

pins

003-pins.JPG

main.c

#include "project.h"
#include "stdio.h"

#define STR_BUF_LEN 64
#define BIT_DELAY_US 104 /* 9600Hz -> 104.17us */

void soft_tx_send_byte(uint8_t data)
{
    uint8_t mask = 0x01 ;
    int i ;
    
    soft_tx_Write(1) ; /* make sure that the level is high */
    CyDelayUs(BIT_DELAY_US * 2) ;
    soft_tx_Write(0) ; /* generate start bit */
    CyDelayUs(BIT_DELAY_US) ;
    for (i = 0; i < 8; i++ ) {
        if (mask & data) {
            soft_tx_Write(1) ;
        } else {
            soft_tx_Write(0) ;
        }
        mask <<= 1 ;
        CyDelayUs(BIT_DELAY_US) ;
    }
    soft_tx_Write(1) ; /* generate stop bit */
    CyDelayUs(BIT_DELAY_US * 2) ;
}

void soft_tx_send_string(char *str)
{
    while(str && *str) {
        soft_tx_send_byte(*str++) ;
    }
}

int main(void)
{
    char str[STR_BUF_LEN+1] ;
    int count = 0 ;
    
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    soft_tx_send_string("\x1b[2J\x1b[;H") ;
    soft_tx_send_string("Test Software UART TX ") ;
    snprintf(str, STR_BUF_LEN, "(%s %s)\n\r", __DATE__, __TIME__) ;
    soft_tx_send_string(str) ;

    for(;;) {
        snprintf(str, STR_BUF_LEN, "count %d\n\r", count++) ;
        soft_tx_send_string(str) ;
        CyDelay(1000) ;
    }
}

Then I connected a USB-serial adapter to P3_0 and PC.

The Tera Term log was something like

001-TeraTerm-log.JPG

moto

0 Likes
KyTr_1955226
Valued Contributor

Hi MotooTanaka,

I will probably end up using the Software Transmit UART component for just some basic debug output, but my real burning question is why can't I place a UDB UART even when I should have the resources to do so according to the resource meter in PSoC Creator.  Hoping someone with some more knowledge than I have of how the UDBs work would be able to shed some light on why this might be the case.

In any event, that code for a simple software UART could come in handy elsewhere.  Appreciated!

 

0 Likes
odissey1
Honored Contributor II

KyTr,

As Rodolfo pointed out, your design is likely runned out of routing resources (P-terms), which are used by 80% (299 out of 384). That is typically the limit of wiring network.

     Try using Fixed Function UARTs (4 available), and replace some UDB-based UARTs.

/odissey1

0 Likes
KyTr_1955226
Valued Contributor

Hi Odissey,

I don't think this part has fixed UARTs unless I am missing something?  Something like an I2C, PWM, or Timer component has a FF/UDB selector in the component config.  I see no such thing for the UARTs (and none are listed under "Communication" on the resource meter).

I did find my Master I2C component for this project was UDB though, where I can be using FF.  Making this change took UDB usage from 76% to 66% and gave me nearly 40 Macrocells and 100 P-Terms back.  This lets me fit another UART with no trouble.  If I reconfigure my timers and make one of my PWM modules FF, I might be able to save even more.

Thanks for the tip on P-Terms, I'll bear that in mind here on out.

0 Likes
RodolfoGL
Employee

Hi all,

It is actually impossible to use 100% of the Macrocells or Pterms. Due to routing restrictions, you might not be able to use all the inputs/outputs of the PLDs. Said that, if you reach around 85~90% of a Macrocells or Pterms, the placer might not be able to fit your design.

View solution in original post

KyTr_1955226
Valued Contributor

Hi Rodolfo,

Thanks for the tip, I'll mark this as solution to the question. 

I did manage to recover some P-Terms and Macrocells by taking my Master I2C component from UDB to FF.  Since this design was based on an older one (that had both SI2C and MI2C) I removed the unneeded Slave I2C, but neglected to switch the Master I2C to FF.  It was costing me lots of UDB (to the tune of 100 P-Terms and 40 macrocells).  With this change I was able to fit my extra UART.

Thanks!

0 Likes