Embedded Systems Conference
Breaking News
Comments
Max The Magnificent
User Rank
Author
Being prodded into action
Max The Magnificent   6/27/2014 3:12:00 PM
NO RATINGS
Hi Aubrey -- I have one each of the PSoC 4100 and 4200 prototyping kits sitting on my desk -- and also a PSoC 4 Pioneer Kit -- your blogs are prodding me into action with regard to using them in one of my hobby projects.

betajet
User Rank
Author
"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.

antedeluvian
User Rank
Author
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");

 

Garcia-Lasheras
User Rank
Author
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
Author
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.

antedeluvian
User Rank
Author
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.

KB3001
User Rank
Author
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
Author
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.

mithrandir
User Rank
Author
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.

mithrandir
User Rank
Author
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.

Wilton.Helm
User Rank
Author
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.



Radio
NEXT UPCOMING BROADCAST
Drones are, in essence, flying autonomous vehicles. Pros & cons surrounding drones today might well foreshadow the debate over the development of self-driving cars. In the context of a strongly regulated aviation industry, "self-flying" drones pose a fresh challenge. How safe is it to fly drones in different environments? Should drones be required for visual line of sight, as are piloted airplanes? Is the technology advancing faster than we can answer the questions it poses? Panelists: Chad Sweet, Director of Engineering, Qualcomm; Yannick Levy, VP Corporate Business Development, Parrot; Jim Williams, ex-FAA drone chief; Michael Drobac, Exec. Director, Small UAV Coalition; Moderator: Junko Yoshida, Chief Int'l Correspondent, EE Times
July 16, 1pm EDT Thursday
IoT Network Shoot Out
Top Comments of the Week
Flash Poll
Like Us on Facebook

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
Special Video Section
LED lighting is an important feature in today’s and future ...
Active balancing of series connected battery stacks exists ...
After a four-year absence, Infineon returns to Mobile World ...
A laptop’s 65-watt adapter can be made 6 times smaller and ...
An industry network should have device and data security at ...
The LTC2975 is a four-channel PMBus Power System Manager ...
In this video, a new high speed CMOS output comparator ...
The LT8640 is a 42V, 5A synchronous step-down regulator ...
The LTC2000 high-speed DAC has low noise and excellent ...
How do you protect the load and ensure output continues to ...
General-purpose DACs have applications in instrumentation, ...
Linear Technology demonstrates its latest measurement ...
10:29
Demos from Maxim Integrated at Electronica 2014 show ...
Bosch CEO Stefan Finkbeiner shows off latest combo and ...
STMicroelectronics demoed this simple gesture control ...
Keysight shows you what signals lurk in real-time at 510MHz ...
TE Connectivity's clear-plastic, full-size model car shows ...
Why culture makes Linear Tech a winner.
Recently formed Architects of Modern Power consortium ...
Specially modified Corvette C7 Stingray responds to ex Indy ...