The target program has stopped at: file: main.c line: 16 function: main address: 0x00000084

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

cross mob
swch_4772531
Level 3
Level 3
10 replies posted 10 likes given 5 replies posted

I am trying to output the ADC value onto my LCD screen. I am using PSoC 5LP CY8C5888LTI-LP097

#include "project.h"

#include <stdio.h>

int main(void)

{

    CyGlobalIntEnable;

   

    LCD_Start();

    ADC_Start();

   

    int32 adcResults;

    float adcVolts;

    char tmpstr[25];

   

   

    LCD_Position(0,0);

    LCD_PrintString("ADC WORKING");

   

    ADC_StartConvert();

   

   if(ADC_IsEndConversion(ADC_RETURN_STATUS) !=0 ){

    adcResults = ADC_GetResult32();

    adcVolts = ADC_CountsTo_Volts(adcResults);

    sprintf(tmpstr,"%+1.3f Volts",adcVolts);

   

    LCD_Position(1,0);

    LCD_PrintString(tmpstr);

    }

  

}

This program breaks on line 16. I am new to PSoC, so please guide me on where am I going wrong...

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Swetha-san,

> It is working !!!

Congratulations!

> I changed the port to P2.1-P2.7. No IC heating now And i have removed all the resistors.

That is a very interesting observation!

As I also ordered LCDs I did the following tests.

(1) I used P2[6:0] without resistors.

The program worked, but as you wrote KitProg's PSoC got warm,

but IMHO, it was not as bad as I would think dangerous.

IMG_4555.JPG

(2) I added 10K resistors, now the heat is not as bad as (1).

IMG_4556.JPG

(3) I tested using P2[7:1], it was working OK, but I could not tell if the heat was less.

IMG_4557.JPG

(4) I tested using P12[6:0], now the position of letters were wrong.

I suspect that this was caused by the pull-up resistors applied to I2C pins (P12[1:0])

IMG_4558.JPG

(5) I tested using P12[7:1], similar to (4), letter locations were corrupted.

IMG_4559.JPG

(6) I tested using P3[6:0], I think that the Bypass Cap at P3[2] is preventing the module from working.

IMG_4560.JPG

(7) When I tried P1[6:0], PSoC Creator refused to assign them as SWD pins were included.

Note: If we disable SWD from DWR > System, it could be done, but I decided to stop here.

So after all, current conclusion of mine is that without modifying CY8CKIT-059,

P2[6:0] or P2[7:1] are the only 2 combinations to be used for the LCD Char Component.

Although I could not tell why P2[7:1] generates less heat, if it works for you please go with that configuration.

Another thing I noticed/realized during my tests, it is very easy to mistake the connections of RS and RW,

and when I mistook, I saw the display similar to your problem(s).

Anyway, I hope that we can call it a day 😉

Best Regards,

16-Dec-2020

Motoo Tanaka

View solution in original post

22 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I'm afraid that I may sound pedantic in this response,

but I hope that you can put up with me...

In the world of embedded application, often there is no OS (operating system).

In such case, a program is almost like an OS, basically it should not end.

Or the processor will keep running after the last command...

So usually we have an infinite loop at the end of the program

to prevent the processor go too far.

But your program did not have the loop to keep the processor stay within your control,

the library stopped the process after the last command.

So please try to write a program basically in the following style.

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

int main(void)

{

    do_initialization() ;

   for (;;) {

       do_something() ;

   }

   /* so we will never reach here */

}

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

Another thing often bothers us, is handling of float values.

Please refer to the following URLs about this topic

Printing floating-point values in PSoC Creator - KBA231059

printf and float rhapsody (aka, yet another printf and floating topic)

Having written above, I tried with CY8CKIT-059, which has CY8C5888LTI-LP097.

Schematic

Note: As I don't have a LCD, I used a UART instead.

002-schematic.JPG

Pins

003-pins.JPG

main.c

Note: From #define USE_UART 1 to #endif is for imitating LCD using UART,

so if you have LCD, just define USE_UART 0.

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

#include "project.h"

#include <stdio.h>

#define USE_UART 1

#if USE_UART

#define ESC '\033'

char vt100_str[32] ;

void print(char *str)

{

    UART_PutString(str) ;

}

void cls(void)

{

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

    CyDelay(20) ;

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

    CyDelay(20) ;

}

void locate(int x, int y)

{

    sprintf(vt100_str,"%c[%d;%dH",ESC,y,x) ;

    print(vt100_str) ;

}

void LCD_Start()

{

    UART_Start() ;

    cls() ;

}

void LCD_Position(int y, int x)

{

    locate(x+1, y+1) ;

}

void LCD_PrintString(char *str)

{

    print(str) ;

    print("\n\r") ;

}

#endif

int main(void)

{

    CyGlobalIntEnable;

    LCD_Start();

    ADC_Start();

    int32 adcResults;

    float adcVolts;

    char tmpstr[25];

    LCD_Position(0,0);

    LCD_PrintString("ADC WORKING");

    for (;;) {

        ADC_StartConvert();

        ADC_IsEndConversion(ADC_WAIT_FOR_RESULT) ;

        adcResults = ADC_GetResult32();

        adcVolts = ADC_CountsTo_Volts(adcResults);

        sprintf(tmpstr,"%+1.3f Volts",adcVolts);

        LCD_Position(1,0);

        LCD_PrintString(tmpstr);

       

        CyDelay(1000) ;

    }

}

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

Tera Term log

001-TeraTerm-log.JPG

moto

Thank you for replying...

I tried the above code with LCD, I could see two lines getting printed on the LCD as shown below,

pastedImage_1.png

pastedImage_0.png

The LED1 is not glowing also, the kitprog chip gets heated. Could you please help....

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

> The LED1 is not glowing also, the kitprog chip gets heated. Could you please help....

First of all, please re-check all the connections, it there is/are any shorts between wires.

Meantime, may be the LCD is drawing too much current,

if it's the case please try add some resistors between the pins of PSoC and the LCD.

About not seeing number before "Volts",

please refer to these links.

Printing floating-point values in PSoC Creator - KBA231059

printf and float rhapsody (aka, yet another printf and floating topic)

moto

P.S. For the float number, please

(1) Project > Build Settings > Linker > General

   set "Use newlib-nano Float Formatting" to True

(2) Project > Design Wide Resources > System

Expand the heap size from 0x80 to 0x200 (value may vary depending on your requirement)

Thank you so much....

It is working!!!

But I see CY8C5868LTI-LP039 chip on kitprog is getting heated, Im worried about that....I tried adding resistors between Vcc of the PSoC and that of LCD

pastedImage_0.png

Thank you once again for your help

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

> It is working!!!

I'm glad hearing that 😉

> But I see CY8C5868LTI-LP039 chip on kitprog is getting heated,

> Im worried about that....I tried adding resistors between Vcc of the PSoC and that of LCD

Maybe the heat is in a reasonable range. (I'm not sure at this point)

Can you test the program without connecting the LCD?

And touch the KitProg, if it heats about the same, then it may be OK.

But if it does not heat a lot without the LCD, but heat a lot with the LCD, probably the LCD is causing the heat.

It would be helpful, if you can post the connection diagram of your system.

(connection between CY8CKIT-059 and the LCD, and other connections if there is/are any)

Although I'm not an expert of hardware, there are many community members who are experts of that subject.

Meantime,  I would try to provide Vcc to the LCD from the KitProg's VBUS (5V), so the the power will be provided directly from USB VBUS.

moto

Hii

Thank you for replying....

Here is my connection diagram. +5V is connected to VDD onchip

pastedImage_0.png

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Attached is the LCD connection part from CY8CKIT-050

https://www.cypress.com/documentation/development-kitsboards/cy8ckit-050-psoc-5lp-development-kit

It seems that each signal connection has 10K ohm resistors.

001-from-050.JPG

moto

I have added 10k resistors between the signal connection, now the blue LED is glowing. Also, the IC is not getting heated much as before.

But I can see no output on LCD. It looks like this:

pastedImage_0.png

I have cross checked my connection. Everything seems perfect

Where could I possibly go wrong? Am I missing anything?

Could you please guide...

swetha

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Swetha-san,

> I have added 10k resistors between the signal connection, now the blue LED is glowing. Also, the IC is not getting heated much as before.

This is good news!

I think that you are almost there.

> But I can see no output on LCD. It looks like this:

But this is bad news.

I think that you may have made some miss-connections.

So could you post updated (exact) connection diagram?

Best Regards,

14-Dec-2020

Motoo Tanaka

Thank you for replying.

Please find the Circuit Diagram below. The KitProg USB is inserted into my Laptop.

pastedImage_0.png

Thank you

swetha

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Swetha-san,

Thank you for the updated diagram!

I compared

1st Diagram

The schematic from CY8CKIT-050

2nd Diagram

010-pin-list.JPG

Among these pins, following pins are connected for some other use in CY8CKIT-059

011-059-Pins.JPG

The cells filled in Yellow can have some problems.

(A) In the 2nd Diagram, you connected 100 ohm to between VDD to + 5V, this may not be required

(B) P2[1] is also connected to LED on CY8CKIT-059, this may be causing problem.

I would try ...

(0) Adjust POT connected at V0

(1) Remove 100 ohm between VDD and +5V (Pin1)

(2) If still having problem, return P2[6:0] to P12[6:0]

  as you could see the LCD output with this pin configuration.

  But please keep 10K for these pins.

Best Regards,

15-Dec-2020

Motoo Tanaka

Hello,

Thank you for replying

I tried the following ways :

-> Connected to P12.0 - P12.6 with 10k resistors for each signal connection.

    Results: No output on LCD. The LCD was just glowing but printing nothing. No heating of IC

->  Connected to P3.0 - P3.6 with 10k resistors for each signal connection.

    Results: Glows all the pixels of both the lines of LCD but prints nothing. No heating of IC

-> Connected to P12.0 - P12.6 without 10k resistors for each signal connection.

    Results: Getting output. Heating of IC

For all the above cases, I removed the 100 Ohm resistor. And adjusted V0 every time.

Any other suggestions, please?

I sincerely thank you for your time

Swetha

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Swetha-san,

Thank you very much for testing many cases.

> For all the above cases, I removed the 100 Ohm resistor. And adjusted V0 every time.

I think that this is OK.

> Any other suggestions, please?

From your result, P12.0 - P12.6

(1) With 10K : No Output. No Heating

(2) Without 10K : Getting Output. IC Heating.

Direct connection seems to draw too much current

but 10K seems to make the current to low, or not enough.

How about try using 1K ~ 5K Ohm for P12.0 ~ P12.6.

I would start with 1K and see if there will output and/or heat.

Best Regards,

15-Dec-2020

Motoo Tanaka

It is working !!!

I changed the port to P2.1-P2.7. No IC heating now And i have removed all the resistors.

Thankk you sooo much

swetha

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Swetha-san,

> It is working !!!

Congratulations!

> I changed the port to P2.1-P2.7. No IC heating now And i have removed all the resistors.

That is a very interesting observation!

As I also ordered LCDs I did the following tests.

(1) I used P2[6:0] without resistors.

The program worked, but as you wrote KitProg's PSoC got warm,

but IMHO, it was not as bad as I would think dangerous.

IMG_4555.JPG

(2) I added 10K resistors, now the heat is not as bad as (1).

IMG_4556.JPG

(3) I tested using P2[7:1], it was working OK, but I could not tell if the heat was less.

IMG_4557.JPG

(4) I tested using P12[6:0], now the position of letters were wrong.

I suspect that this was caused by the pull-up resistors applied to I2C pins (P12[1:0])

IMG_4558.JPG

(5) I tested using P12[7:1], similar to (4), letter locations were corrupted.

IMG_4559.JPG

(6) I tested using P3[6:0], I think that the Bypass Cap at P3[2] is preventing the module from working.

IMG_4560.JPG

(7) When I tried P1[6:0], PSoC Creator refused to assign them as SWD pins were included.

Note: If we disable SWD from DWR > System, it could be done, but I decided to stop here.

So after all, current conclusion of mine is that without modifying CY8CKIT-059,

P2[6:0] or P2[7:1] are the only 2 combinations to be used for the LCD Char Component.

Although I could not tell why P2[7:1] generates less heat, if it works for you please go with that configuration.

Another thing I noticed/realized during my tests, it is very easy to mistake the connections of RS and RW,

and when I mistook, I saw the display similar to your problem(s).

Anyway, I hope that we can call it a day 😉

Best Regards,

16-Dec-2020

Motoo Tanaka

Hello Swetha.  Hello Mooto.

The reason KIT-050 includes 10k Ohm resistors on LCD, is to provide different voltage options (via several jumper options on board).

Lets say PSOC is powered from 3.3V and LCD is powered from 5V.  In order to not burn out the input clamping diodes on PSOC when LCD is read, the 10k Ohm resistors will limit the current to a safe level.

Lets say PSOC is powered from 5V and LCD powered from 3.3V.  In order to not burn out the input clamping diodes on LCD when PSOC writes to LCD, the 10k Ohm resistors limit current to a safe level.

When both PSOC and LCD are powered with same voltage, 10k Ohm resistors are not necessary.

I also did experiment with LCD connected to Kit-059 P0[6:0].  I removed capacitors C9, C12, C13, and no 10kOhm resistors.

I powered KIT-059 from Kitprog USB connector and there was no heat.

I then powered KIT-059 from micro USB connector (similar to Swetha configuration), and there was some heat in Kitprog (not very much heat).

If both KIT-059/Kitprog USB connectors are connected into PC port, there is no heat.

I think when KIT-059 is powered from micro USB connector, the Kitprog 5LP is being back-powered through its pin protection clamp diodes of SWD, I2C (including body diodes of U3 FETs) and UART connections to target 5LP.  This is not a good thing to do.

I snap off Kitprog and installed headers.  This makes it easy to program other projects and avoids the heat issue when using KIT-059 micro USB port.

Good luck with your project Swetha.

Hello BiBi,

Thank you this was very insightful !

Regards

Swetha

Thank you, this gives me more clarity of what all I have tried

Very Helpful. Now I understand.

I can recollect, a few days back I read, that there are few bypass capacitors.

```

Bypass capacitors are present on all boards.

Here are a few that I was able to briefly see:

CY8CKIT-042:       P1.7(C10)   P4.2(C1)   P4.3(C9)

CY8CKIT-049-42xx:  P1.7( C3)   P4.2(C2)   P4.3(C11)

CY8CKIT-050:       P0.2(J43)   P0.4(J44)

CY8CKIT-059:      P0.2(C12)   P0.3(C13)  P0.4 (C9)   P3.2(C7)   P5.4(C4)

```

Reference : https://community.cypress.com/thread/14238

Thank you

Swetha

swch,

I'm glad your up and working.

The main reason your PSoC chip is heating up is that you are trying to drive too much current from one or more outputs.

You have not presented enough information as to all the devices you are trying to drive and how they are connected.

Here are some excerpts from an AppNote AN72382 https://www.cypress.com/file/45381/download ,

pastedImage_1.png

pastedImage_2.png

Len

Len
"Engineering is an Art. The Art of Compromise."
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

swch,

What is the part number of your LCD display?

Len

Len
"Engineering is an Art. The Art of Compromise."

Hello Len,

Part number : JHD162A

Swetha

0 Likes