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

PSoC™ 4

BiBr_4596811
Level 2
5 replies posted 5 questions asked 5 sign-ins
Level 2

Hi,

Is anyone used software uart in PSOC 4100 plus.

I have ported Arduino SoftwareSerial library but it didn't succed

Please help me to make software Uart receive library for it.

Thank You

Bivay

0 Likes
1 Solution
BiBr_4596811
Level 2
5 replies posted 5 questions asked 5 sign-ins
Level 2

I got solution using pin interrupt to be used and manual reading of pin state with delay.

Thank You

View solution in original post

0 Likes
6 Replies
Vasanth
Moderator
Moderator 500 solutions authored First question asked 1000 replies posted
Moderator

Hi,

Software UART component is already available in the device. Kinldy check the component catalog  for the device.

pastedImage_0.png

Best Regards,
Vasanth

0 Likes
BiBr_4596811
Level 2
5 replies posted 5 questions asked 5 sign-ins
Level 2

Thanks for reply,

Bu, I didn't asked for Software Uart Transmit .

I know about it.

I asked for software based uart receive. as I didn't find any support about receiver of uart.

Please help if available.

Thank You

Bivay

0 Likes
MotooTanaka
Level 9
First comment on KBA 1000 replies posted 750 replies posted
Level 9

Hi,

As /odissey1-san stated above, using UART component must be much easier and more reliable.

But just for fun, I tried with my (wing-less) CY8CKIT-149.

Schematic

001-schematic.JPG

Pins

NOTE: I needed jumper P7[0] and P2[0] to use the KitProg USB-Serial port for testing.

002-Pins.JPG

main.c

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

#include "project.h"

#include "stdio.h"

#define HALF_BIT 52   /* 9600Hz -> 104.17us = 1bit time */

volatile int start_bit_flag = 0 ;

volatile uint8_t rx_data = 0 ;

#define STR_LEN 64

char str[STR_LEN+1] ;

void print(char *str)

{

    HARD_UART_UartPutString(str) ;

}

CY_ISR(start_bit_isr)

{

    soft_rx_ClearInterrupt() ;

    soft_rx_isr_Disable() ;

    start_bit_flag = 1 ;

}

uint8_t receive_byte(void)

{

    uint8_t data = 0 ;

    uint8_t mask = 0x01 ;

    int i ;

    CyDelayUs(HALF_BIT*2) ;

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

        data |= soft_rx_Read() ? mask : 0 ;

        mask <<= 1 ;

        CyDelayUs(HALF_BIT * 2) ;

    }

    // no parity

    //   doing nothing for party

    // waiting for stop bit

    while(soft_rx_Read() == 0) {

        CyDelayUs(HALF_BIT) ;

    }

    return( data ) ;

}

void cls(void)

{

    print("\033c") ; /* reset */

    CyDelay(20) ;

    print("\033[2J") ; /* clear screen */

    CyDelay(20) ;

}

void splash(void)

{

    cls() ;

    print("Soft UART Test") ;

    snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */  

      

    HARD_UART_Start() ;

  

    soft_rx_isr_StartEx(start_bit_isr) ;

  

    splash() ;

}

int main(void)

{

    uint8_t rx_data = 0 ;

  

    init_hardware() ;

  

    for(;;)

    {

        if (start_bit_flag) {

            rx_data = receive_byte() ;

            HARD_UART_UartPutChar(rx_data) ;

            start_bit_flag = 0 ;

            soft_rx_ClearInterrupt() ;

            soft_rx_isr_ClearPending() ;

            soft_rx_isr_Enable() ; 

        }

    }

}

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

Tera Term Log

Note: My Tera Term is set as "Local Echo" so if we see same letters twice

that means the letter typed in the terminal was received by the soft_uart_rx

and sent back via the "HARD_UART"

000-teraterm-log.JPG

moto

BiBr_4596811
Level 2
5 replies posted 5 questions asked 5 sign-ins
Level 2

I will try to use your solution thanks

odissey1
Level 9
First comment on KBA 1000 replies posted 750 replies posted
Level 9

Bivay,

Check this UART Rx demo showing receiving simple commands from the terminal using SCB UART to control RGB LED on PSoC4200. There might be some differences with PSoC4100, but it should be helpful

Re: How to use 4 Uart in Psoc 4

/odissey1

BiBr_4596811
Level 2
5 replies posted 5 questions asked 5 sign-ins
Level 2

I got solution using pin interrupt to be used and manual reading of pin state with delay.

Thank You

0 Likes