- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have just posted this to a discussion below for a possible solution.
But as this could be useful when you have used up all UART components and you need yet another UART TX,
I'm posting this here, too.
schematic
pins (or "a pin" ?)
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) ;
}
}
Tera Term log
moto
- Labels:
-
PSoC 5LP
-
Software UART TX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Moto-san,
Thank you for sharing this project with the community and for your interest in our products.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
moto-san,
Thank you for posting your SW UART Tx project.
I'm a little confused. Is there a SW Tx UART already in the components lib from Infineon?
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Len-san,
Thank you for your pointing out this.
I also thought about that component, but as I was not sure if the component was available for this device, I wrote one manually.
Probably using available component must be a better/safer.
moto