Breaking News
Comments
Newest First | Oldest First | Threaded View
Page 1 / 2   >   >>
Wilton.Helm
User Rank
Rookie
PSoC 4 comments
Wilton.Helm   7/1/2014 5:52:24 PM
NO RATINGS
I expect changing from debug to release to change optimizations, although it should be overridable (some compilers are weak here).  Debugging optimized code is almost impossible, as some variables exist only in registers, common code elements are re-used and the physical ordering of instructions may not resemble the source code ordering.  The bottom line is that debugging optimized code involves at a minimum frequent unexpected bouncing around in the source.

As previously stated, volatile is a useful keyword.  It is also used for variables that may be changed by an interrupt. 

However, the clean way to do timed stuff is with a timer.  In its simplest form, set a hardware timer to some useful rate (generally between 1 us and 1 ms) and read it repeatedly until sufficent counts elapse.  A software tick timer updating a volatile variable is another (and more common) way to do the same thing, particulalry if the time interval required is in the ms range rather than us.  The more elegant approach for ms scale delays is to capture a start value and then go do something else, while checking back periodically to see if the interval has elapsed.  If precision is required, when the interval is nearly over it can hang in a loop for the last few counts.  Of course with the rich timer resources of the PSoc, a dedicated hardware timer and some logic is an even better alternative.  (BTW the major league part in this game is the Zynq, which has two A9 cores and about 100,000 gates of logic.)

I just found out about the $4 4200 proto kit a week or so and order half a dozen, four of which will soon be part of a project I have been meaning to do for several years.  I haven't plugged one in, yet, but am looking forward to it.  If I understand it right, the 4200 can implement six UARTS in hardware (two fixed and four as digital blocks--one is required for downloading and debugging).  Twelve bit ADC is a luxury for this type of chip, too, not to mention 32 bit RISC core, even if it is only M0.

mithrandir
User Rank
Rookie
Re: That annoying debug issue
mithrandir   6/30/2014 1:11:35 AM
NO RATINGS
Oh and in case anyone is interested(note my shameless promotion here),

http://www.embedded.com/design/real-world-applications/4428811/Building-an-electronic-guitar-digital-sound-synthesizer-using-a-programmable-SoC

It uses PSoC5.

mithrandir
User Rank
Rookie
That annoying debug issue
mithrandir   6/30/2014 12:14:18 AM
NO RATINGS
Yeah the interrupt bug can be quite annoying, I ran into it several times.

If the interrupt isn't quite as critical for what you want to debug, you can disable breakpoints while debugging in Creator(I remember a little lightning symbol which can disable all global interrupts). Not an elegant solution but can work sometimes.

Moving some of my hobby stuff from PSoC5 to PSoC4 felt like quite a step back for me though. You get so used to any pin anywhere you forget that PSoC4 has a quite a few fixed function pins as well. For the sweet price point though, its well worth the sacrifice.

antedeluvian
User Rank
Blogger
Re: "volatile"
antedeluvian   6/29/2014 8:49:28 PM
NO RATINGS
Javi

Do I need to buy a Keil license in order to work with the PSoC 4 device or everything I need is included in the Cypress toolchain?

No you don't have to buy anything. I think there is an option which will improve code density or something like that, but so far I haven't bumped into any limitations (and I have used it on the PSoC5 as well). However you do have to register with Keil.

antedeluvian
User Rank
Blogger
Re: Debugging
antedeluvian   6/29/2014 8:46:20 PM
NO RATINGS
KB3001

Did you consider using Keil MDK for software development especially debugging?

No. I stayed within PSoC Creator.

KB3001
User Rank
CEO
Re: "volatile"
KB3001   6/29/2014 6:42:49 PM
NO RATINGS
@Garcia-Lasheras, there is a free Keil download (from www.keil.com) although it's 32k code size limited. I believe PSoC creator uses keil MDK in the background.

Garcia-Lasheras
User Rank
Blogger
Re: "volatile"
Garcia-Lasheras   6/29/2014 5:12:22 PM
NO RATINGS
@Antedeluvian: The idea has been bouncing around in my head for some time now, but after reading your blogs, I'm completely sure I want to try one of these PSoC devices ;-)

About the ARM code, you have mentioned Keil compiler. Do I need to buy a Keil license in order to work with the PSoC 4 device or everything I need is included in the Cypress toolchain?

 

KB3001
User Rank
CEO
Debugging
KB3001   6/29/2014 11:49:20 AM
NO RATINGS
Did you consider using Keil MDK for software development especially debugging?

antedeluvian
User Rank
Blogger
Re: "volatile"
antedeluvian   6/27/2014 4:04:56 PM
NO RATINGS
betajet

Most C compilers let you declare a variable to be "volatile", e.g.,

    volatile int cDummy;

which tells the compiler not to optimize loads and stores to that variable.  "volatile" is mostly used to identify a variable as memory-mapped I/O, which means it could change value any time, e.g., if it's the current value of GPIO pins.  Writes to a volatile variable may have side-effects like shifting data out though a UART pin.  "volatile" is also used for variables that are shared with interrupt service routines or other tasks


Thanks for pointing this out. However, it seems to me that I adopted a rather poor and even inelegant method of creating code usage. It would have been better of me to adopt the use of assembly instructions like asm ("nop");

 

betajet
User Rank
CEO
"volatile"
betajet   6/27/2014 3:48:48 PM
NO RATINGS
Aubrey wrote: ... the compiler had optimized away the dummy memory accesses like cDummy++; ...

Most C compilers let you declare a variable to be "volatile", e.g.,

    volatile int cDummy;

which tells the compiler not to optimize loads and stores to that variable.  "volatile" is mostly used to identify a variable as memory-mapped I/O, which means it could change value any time, e.g., if it's the current value of GPIO pins.  Writes to a volatile variable may have side-effects like shifting data out though a UART pin.  "volatile" is also used for variables that are shared with interrupt service routines or other tasks.

Page 1 / 2   >   >>


EE Life
Frankenstein's Fix, Teardowns, Sideshows, Design Contests, Reader Content & More
Max Maxfield

Aging Brass: Cow Poop vs. Horse Doo-Doo
Max Maxfield
9 comments
As you may recall, one of the things I want to do with the brass panels I'm using in my Inamorata Prognostication Engine is to make them look really old. Since everything is being mounted ...

EDN Staff

11 Summer Vacation Spots for Engineers
EDN Staff
11 comments
This collection of places from technology history, museums, and modern marvels is a roadmap for an engineering adventure that will take you around the world. Here are just a few spots ...

Glen Chenier

Engineers Solve Analog/Digital Problem, Invent Creative Expletives
Glen Chenier
11 comments
- An analog engineer and a digital engineer join forces, use their respective skills, and pull a few bunnies out of a hat to troubleshoot a system with which they are completely ...

Larry Desjardin

Engineers Should Study Finance: 5 Reasons Why
Larry Desjardin
45 comments
I'm a big proponent of engineers learning financial basics. Why? Because engineers are making decisions all the time, in multiple ways. Having a good financial understanding guides these ...

Flash Poll
Top Comments of the Week
Like Us on Facebook
EE Times on Twitter
EE Times Twitter Feed

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)