Simple PIN project size problem?

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello everyone,

   

I started my experience with Psoc4 and designed simple project with one PIN being set to logical 1. I'm surprised that after building this project it used: 

   

Flash used: 1664 of 32768 bytes (5,1%).
SRAM used: 1428 of 4096 bytes (34,9%). Stack: 1024 bytes. Heap: 128 bytes.

   

and 3 IO and 1 UDB. What is more PSoc Creator generated many directories within the project (like cy_boot etc). I attached screenshoot of the PSoc Creator

   

Why???? What could I do to make the file smaller? Robert

   

PS. In AVR architecture it would use few bytes.

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

Welcome in the forum!

   

No need to make the file smaller yet. Even a Zero project (No code, no components) will use about the same amount of flash as your project. This is because of the needed initialization: Every internal switch has to be programmed to a defined position and that data takes some flash. Most of the sram used are for the stack (1kB) which of course is quite too much for your project, but leave the setting untouched for the moment. You ought to increase the heap to 0x0200 when you are using printf().

   

The allocated folders make up your complete project giving the toolchain the opportunity of keeping track of component updates, compiler settings etc.

   

You are probably using debugging which requires 2 pins. I cannot tell what an USB was used for. Can you please 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.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Bob,

   

It is a bit disappointing,. I mean flash and RAM size. Probably it comes from the fact that I have been writing code for AVR for many years and the same program for the AVR would engage few bytes. Anyway, I don't want to use debugger and debugging options, so maybe it would smaller the size? I have CY8CKIT-042 PSoC® 4 Pioneer Kit. The project was attached. Best regards... Robert

   

PS.

   

Could you explain what does exactly mean the HW connection for digital output?

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

Opposite to your AVR CPU a PSoC has configurable routable hardware which you can use freely. The running hardware does not require CPU intervention, only for starting or property changes on-the-fly a piece of code is needed. This is making a Programmable System On a Chip. Even using Warp Verilog as HDL (Hardware Definition Language) allows you to define your own hardware component(s). Quite a bit different to an AVR. PSoCs are not intended to run an OS, but doing their job as an embedded processor. Typical apps are controlling, closed loops etc.

   

Having the opportunity to debug the code (setting breakpoints, inspecting variables etc.) should not be under estimated. I am programming a lot on a daily base, but I have to admit that I do make mistakes. Debugger is a friend and a great help in these cases. Switching debugging off does not change the code size.

   

Could you explain what does exactly mean the HW connection for digital output? The output pin has to get its signal from either an internal signal path (could be the output of a PWM...) or can be set programmatically, both do not work. The HW connection chooses between one and the other. Same is for input pins.

   

Need more flash and sram? Have a look at the CY8CKIT-043 PSoC4 M or a CY8CKIT-059 PSoC5 Prototyping Kit.

   

Allow me a simple question: What do you want to perform?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

What I'd like to perform? I'd like to see the ARM architecture advantage compared to the AVR. Specially speed, PSoC designing simplicity etc. But the code size generated by the compiler is a bit disappointing. I know, there is a different architecture but I suppose that there would be any advantage in speed due to overhead... Robert

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

Robert,

   

you even did not touch the surface of the ARM CPU. The flash needed was for initializing the PSoC hardware. When you want to use an ARM CPU with high speed, get the latest Raspberry board. I managed to put a Quad copter controller with 9 degrees sensor, Mahoney algorithm and servo control into a single PSoC4. Repetition rate was > 50Hz, weight a few grams.

   

PSoC CPUs are running at comparably low speed between 24 and up to 80MHz, a R-PI runs at several 100MHz but you will never be able to toggle a pin with 20MHz speed and still having CPU power for handling interrupts or other tasks. A PSoC is able to control multiple pins at different rates without any CPU usage.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

But about the Stack & Heap size. Couldn't be decreased? If yes, where? Robert

0 Likes
Anonymous
Not applicable

OK. I found them on System Tab, but what are reasonable values? Other task, how to change core clock? R

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

Near the "System" tab is a "Clock" tab. Double click on a clock to open the menu for setting clock specifiers. Creator help menu gives some more info.

   

but what are reasonable values? (for stack size)

   

That depends.. When you use automatic variables (as you should) they will be allocated on the stack, an interrupt (which could be nested) will take ~16*4 bytes on stack. How much stack you need is up to you.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hmm,

   

Can I measure how many bytes for the stack is needed? Probably using the debugger? R

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

Can I measure how many bytes for the stack is needed? Probably using the debugger?

   

Of course: Standard procedure is to pre-populate the stack with a defined pattern (as 0xdeadbeef). After running the project for some times inspect the stack area and see to which depth the pattern is destroyed.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I know, it is well known solution. I rather fought that the IDE/debugger can check this automatically during runtime...R

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

What you have got is a chip-internal debugger interface, not an ICE. Probably when using JTAG you might capture minimum value of SP, but I'm not used to that.

   

 

   

Bob

0 Likes