Uart PutString issue

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

cross mob
Anonymous
Not applicable

Trying to output a 'message' string with the uart, but I only get the first six bytes and then it goes silent.  I thought is may have been the TX buffer, so I increased it to 32 bytes, but that did not fix it.

   

 

   

Here is the UART setup:

   

clock - 3Mhz

   

Baud - 187.5k

   

parity - odd

   

tx buffer- 32bytes

   

rx buffer - 4 bytes

   

Full duplex

   

no interrupts

   

Here is the source code, it's not much:

   

#include <project.h>

   

#define Port3_1
#define Port3_2
char message[18]={"This is jgmDESIGNS"};

   

int main()
{
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
WaveDAC8_1_Start();
LCD_Char_1_Start();
LCD_Char_1_DisplayOn();
LCD_Char_1_PrintString("Hello World");
LCD_Char_1_Position(1,5);
LCD_Char_1_PrintString("Daniel!!");
UART_1_Start(); /* Enabling the UART */
UART_1_PutString(message);

   

/* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
for(;;)
{
/* Set OutputPin state to the
inverse of the InputPin state */
Port3_2_Write( Port3_1_Read() );

}
}

   

 Also,

   

Is there a radio button to put source code in to keep indentation and formatting?

   

 

   

Thanks

   

Jim

0 Likes
11 Replies
Anonymous
Not applicable

Ok, I found a fix, but I have another question that is related:

   

 

   

First the fix,

   

UART_1_Start(); /* Enabling the UART */

   


CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */
UART_1_PutString(message);
for(;;)
{
/* Set OutputPin state to the
inverse of the InputPin state */
Port3_2_Write( Port3_1_Read() );

}
}

   

/* [] END OF FILE */

   

 

   

Enable the interrupt and place the PutString after it.  But then shouldn't the 32byte buffer have been enough to load, and send without the interrupt?

   

 

   

My other question is on how to use the PutArray command correctly?  I am having a little trouble finding an example.

   

 

   

Regards,

   

Jim

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

For UART_Putstring() and _PutArray() the interrupt is needed. It fetches the next character from the buffer and puts it into the transmit-register of the UART.

   

PutString() Transfers a null-terminated string into the buffer (without the NULL) and

   

PutArray() accepts any data-bytes(NULL as well) and relies on the given count-parameter telling how many bytes to transfer.

   

Both functions are "Blocking", which in this case means that the function will wait for room in the buffer and only returns after all bytes have been stored in the buffer. Have a look into the datasheet.

   

 

   

There is no button for keeping indentations of source-text, blame the forum software. Best practice is always to post your complete project, so that we all can have a look at all of your settings? To do so, use

   


Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

This makes a contributor's life easier, just downloading and open the project, getting help from the IDE, easy checking of component versions and, and, and...

 

   

Bob

0 Likes
Anonymous
Not applicable

I did see in the datasheet the notation about the blocking but was not quite sure I understood what they were referring to.  More experimentation is i order, but I am getting to the point where I am going to pull the trgger on the actual design.

   

 

   

Now to do something with teh A/d converter and see what happens.

   

 

   

Thnak you.

   

 

   

Jim

0 Likes
Anonymous
Not applicable

One question though about the PutArray command

   

SAy I have an array of 128 bytes, I do a lookup and find that the data I want to send starts at byte 10, and goes to byte 35, the arrays name is 'message'

   

Can I use:

   

PutArray(message+10,25)

   

TO tell teh command to start at the tenth byte then send the next 25?

   

 

   

JIm

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

PutArray(message+10,25)

   

TO tell teh command to start at the tenth byte then send the next 25?

   

 

   

That should work but the put, to start on 10'th byte, which is array[9]

   

( index numbered 0 - ( # bytes - 1 ) ) should be

   

 

   

PutArray(message+9,25)

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Yes, I should have said 9.

   

 

   

Upon further pondering I am going to try using a variable to represent 9(example) as the lookup will come back with different start/stop points based on the lookup

   

 

   

Hmmmm, I have avoided PSoC's due to a bad original experience many years ago.  Happy to say that I am giving them a second chance, this has been rather pleasant to understand.

   

 

   

Jim

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just for curiosity: What have your bad experiences with PSoC been?

   

And: What development kit or prototype board have you got right now?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

'Bad Experiences" may have been a poor choice of words.

   

BAck in the early 2000's it was suggested to me that I look at teh PSoC since I do a lot of Industrial Process Control work.  SO I went and bought an ExpressEval Kit(still have it) and a bunch of other PSoC mini boards and the lot and went at it.  I looked at the user interface for PSoC designer and shook my head and said WTH.  Went to the few introductory seminars to get it figured out, and once the folks that were running the show found that I only programmed in assembler one of them stopped just short of telling me not to bother comming back until I could program in C, which really pi$$ed me off.  What little local support there was became non-existent and the internet was still in it's infantcy so no place like this.

   

 

   

I said the hell with them all and sat down on my own to try to teach it to myself, but with no one to check what I was doing, I finally said screw it and went back to the way I was doing things.  Anytime I would hear another designer complain about how diffucult the PSoC is only fueled the "Do Not Bother" engine.

   

About a year and a half ago I was talking to another designer about the PSoC and he said again too much trouble.  I was talking to the local Cypress rep about how I might give Cypress another chance but I was not so sure the old gear would be worth the effort.  He brought over a CY8KIT-030 and a CY8KIT-025 and said take these for a ride.  It did not go well, but it was more me this time, but the kits went back up on the shelf.(Side note, I was just getting started in only programming in C at teh time)

   

About four months ago the rep sent me an invitation to another seminar on PSoC4BLE, stay for the whole thing and you get to keep the Pioneer kit. - What the hell I said and I went.  Inside of 40 minutes the Cypress Engineer had me create a usable BLE link and I understood what was going on under the hood.  THAT had me looking at PSoC in a better light.

   

So, now I have another design that I have been working on for the better part of two years using another vendor, but the logistics are not making thingsgo the way I want them.  The client is using a PSoc1 for something and I decided to see what I can do for my design, and so far this has worked out better than I thought.  In the end, after I finish doing my evaluations on the -030 kit I will have to buy the kit for the PSoc5 as I really should be using a 32bit device.  I will pick up a MiniProg3 as well because I do need to see inside the part during debugging.

   

I have also been looking at the FRAM devices as a replacement for EEPROMS.  Much nicer to use

   

So sorry for the long winded response, but I felt it a better answer than "I just did not like......."

   

Cheers! - Jim

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Nice story, Jim!

   

I started with PSoC1 in ~2005, bought an evaluation board and an ICE-Cube and some more equipment. Since I grew up (joke!) with programming languages I had not much problems. I liked those PSoCs from the very beginning on! There was at that time besides the Designer another (poorly working) design entry path that was shortly after abandoned. Right done!!!

   

I still have that PSoC1 equipment, a handfull of chips and some projects but with the PSoC5 LP and the PSoC4-M I am working (designing and building prototypes for my customers)

   

You do not really need a MiniProg3, but when you have your own pcbs built it comes in very handy. All the new "Development Kits" have got a "KitProg" integrated which is a PSoC5 for programming, debugging and USB-UART bridging. Very versatile!

   

The smaller "Prototype Kit" for the PSoC4 has nothing comparable yet and needs BootLoading or a miniprog3.

   

The best right now is to get some CY8CKIT-059 whose only downgrade is the power supply for programming with the KitProg is fixed at 5V which might be difficult for testing with 3.3V hardware connected.

   

The PSoC4-M series is GREAT! Having DMA, more SRam and flash it is a device that might supersede the PSoC1.

   

 

   

Happy coding!

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

PSOC 1 still not quite on deathbed.

   

 

   

1) SC based filters, vs A/D > DFB > VDAC approach in PSOC 3, 5LP

   

2) Faster counters/timers in terms of clock rate

   

3) Smaller packages

   

4) CyFi support

   

5) Powerline support

   

 

   

Just to name a few. The 4, 4 BLE, 4M, 5LP are certainly better cores, but

   

not all designs need ARM core performance. With that being said I would

   

still contact Cypress for lifetime confirmation if starting a PSOC 1 design.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Thanks for the feedback Bob, and Dana

   

 

   

Jim

0 Likes