You are here

PSoC 1 UART + DAC + ADC: RX Data lost //Float to String C ftoa() Code with decimal place definition + negative numbers | Cypress Semiconductor

PSoC 1 UART + DAC + ADC: RX Data lost //Float to String C ftoa() Code with decimal place definition + negative numbers

Summary: 31 Replies, Latest post by Stahldroid on 09 Sep 2016 11:41 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
joh9_1534041's picture
User
61 posts

Hello,

im receive some data (RX) via UART :

1. convert it (atoi()) into a Integer,

2. conver it (itoa()) into a String and sent it (TX) via UART.

Meanwhile, reading 2 voltages (dualadc) and output (dac8) one voltage.

Problem -> If i comment-out all ADC and DAC Code, the UART Communication works fine. But with all User-Moduls + miniCode the UART Communication is faulty (irregular).

:: What can i do?

 

Settings:

Global Settings = 24Mhz, (Vdd/2)+/-(Vdd/2), SC On/Ref High

UART = 9600, Sync to SysClk, 

DUALADC = 8  Bit, CalcTime 45, DUALADC_HIGHPOWER,  PGA_1_HIGHPOWER, PGA_2_HIGHPOWER,

DAC = DAC8_HIGHPOWER
    

Thanks for your reply.

user_1377889's picture
User
10447 posts

"smells" a bit like stack fault or overwritten variables.

Only thing I can see so far (well documented and clean code!!!) is the size of the rx buffer which is currently set to 10 bytes.

1  command, 2 separators, 2 params, 1 zero byte that is 4 bytes left for 2 params. Seems a bit low imho.

 

Bob

user_1377889's picture
User
10447 posts

At second thought... There are more modern chips (which already have got a BLE radio included which could make your design smaller and easier. Ever looked at those PSoC4 chips with a BLE 4.1 radio in a simple module ~10x10x 1.8mm.

 

Bob

joh9_1534041's picture
User
61 posts

Thanks for your fast help! 

I increased the RX-Buffer, but same Problem (see Pics).

My Approach:

1. Check the TX-Data from Device 1 with another UART-PC-Transmitter = Device 1 sends all data correct.

2. Check the TX-Data from Device 2 (.zip) with another UART-PC-Transmitter = Device 2 TX Communication is faulty (irregular).

3. Read AN15576 and the debugger stopped the code on "boot.asm / org 30h, reti(PSoC Block DBB10)".

What does this mean?

 

One another thing, im searching a Prototyping Kit with included Bluetooth Modul and i can only find the PSoC 4 Pioneer Kit. Does Cypress sell another Prototyping Kit + Bluetooth (not separated).

 

Thanks for your reply!

 

 

user_1377889's picture
User
10447 posts

Have a look at this kit.

You obviously have got an ICE-Cube, did you monitor the stack?

And check the status for zero (or pvar for non-zero) after ftoa()

 

Bob

user_1377889's picture
User
10447 posts

... and give this a try:

        csprintf(Buffer,"I-Hall-Eingelesen->%f\n\r",I_Hall_Neu);
        UART_PutString(Buffer);            

You'll need

#include "stdio.h>

char Buffer[40];

 

Bob

joh9_1534041's picture
User
61 posts

Thanks for your help, but csprintf dont work with floats --> Uart Output is black screen (with %d for  decimal = it works)

One other Question: how can i convert negative floats (e.g. -2.344)to string, because ftoa is characterised = /* |input| > 2147483520 *//* |input| < 0.0000001 */  = Out of Range

user_1377889's picture
User
10447 posts

You have to do that yourself, when the number is negative change to a positive and prepend the result with a minus sign.

 

Bob

joh9_1534041's picture
User
61 posts

I did exactly what you say "

... and give this a try:

        csprintf(Buffer,"I-Hall-Eingelesen->%f\n\r",I_Hall_Neu);
        UART_PutString(Buffer);            

You'll need

#include "stdio.h>

char Buffer[40];"

 

with a new Project, but no Uart output. What is wrong? (I reinstalled Psoc Designer 5.4 SP1)

user_1377889's picture
User
10447 posts

I cannot even see your welcomeScreen(). This should work.

 

Bob

joh9_1534041's picture
User
61 posts

Sorry it didn't work.

Log in to post new comments.