At the uni where I work I want to get people onto psocs in the future to replace the PIC micro controllers we use to teach students.
however we need to start with assembly language, just wondered if it is possible to run an assembly only project in psoc creator.
We would need to be able to step through single instructions and see the ALU flags changing. Z N C etc. would love if this was possible because for C stuff psoc rocks!
You may write assembly code and easily include that into a C-main() function but the ARM assembly is not easy to learn since some of the instructions are three-address-instructions. The single-stepping can be done in the IDE: When debugging you may open a "Disassembly"-window and step through the code and watch your CPU-state, PC and SP.
Do not forget that the GCC when enabled optimizes the code so that it is difficult even for a good programming guy to beat the code density and/or execution speed.
C-language was invented to have a machine-oriented programming language that will make assembly unnecessary.
By the way: I just remember that in my education we were taught
and then assembly (all on an IBM mainframe) all in this order.
One instructive exercise is to write simple stuff in C, and also in inline
ASM, and compare the results. Compilers are not yet ASM dense/speed,
but getting pretty close.
Here is an ap note that discusses port bit toggling rates (amongst other
The ap note discusses direct register writes, essentially ASM in another form,
to raise port pin toggling rates.
To get you still more exited about PSoCs and the broad design entry they allow:
There is a HDL (Hardware Definition Language) entry to implement new functions. Take the attached project as an example to implement a serial-in parallel-out shift register example. I apologise not having written any documentation, but this was just a proof-of-concept. Open the project, click in workspace explorer the tab "Components" and look into the .v-file containing the verilog text.
There is an extensive video library on creating components, configuring
UDBs and manipulating Datapath, as well as targeted designs and other
Thanks Dana I will check those out. I imagine it's going to take a long while to master his silicon. So many features..
and Bob I know about he programmable HDL components but I haven't tried it yet, they are programmed in Verilog right?
I want to try and implement an RS485 style UART at some point, I don't care about the voltage levels but just the line driving and whatnot. God and I've not even touched the 5LP series yet. That's next on the agenda
For RS485 just use the UART and check the 485-style. You will need some external drivers to maintain current and/or voltage levels.
When I started with PSoCs i went through all the modules from"Analog" to "System" to get an overview of the capabilities (overwhelming, isn't it?) Then I started some smaller examples on my evaluation kits (Yes! I bought some) and got them to work. So I learnt how to use PSoCs.
How long did that take you? What kinda background did you come from ARM? Or PIC or AVR etc? Also after learning it all which architecture do you spend up your most time with for personal projects. 3,4 or 5?
i feel like I am on a long road to mastering both ARMs and PSoCs but it's an exciting one, these chips are just so fun.
I am coming from the programmer's side having learnt a bunch of different languages and a lot of programming techniques. Then I worked for some decades for a distributor of electronic devices learning to read (and understand) datasheets.
I started with PSoC1 and an ICE-Cube(In-Circuit-Emulator)
Then I got me a KIT-001 which works with PSoC1, 3 and 5.
I do not vote for the PSoC3 since the design of the 8051 was made in 1980 and the core reflects the state-of-the-art of that area which in my opinion is a bit (or even a byte) outdated.
PSoC 4 will take over the market the PSoC1 has containing a modern core (ARM M0) and which is VERY cheap ($1 in quantities). Very good for small projects as temperature or light controlling with CapSense.
PSoC5 is my favourite to work with: ARM M3 Core, lots of hardware inside (although fewer analog capabilities than the PSoC1).
Teaching with PSoCs? What do you need and what do you plan?
What are the prerequisites?
Knowledge of a programming language is essential, and it should be C-language. The use of assembly lacks the transportability between different CPU families. C can even be practiced on the PC, algorithms could be evaluated there and later get transferred to the target system.
Hardware, first of all a PC or Laptop for each student (or group of). A Target system can be as small as the new CY8CKIT-049-42xx which is availlable for $4 but lacks debug capabilities if you do not have got a MiniProg3. So the Pioneer development kit ($25) could be the first approach, the Kit-050 ($99) is a very comfortable one, it comes with an LCD.
What to teach?
Starting with simplest AND OR XOR gates building adders comparators and other basic functions
PLD design with the LUT-component
Analog signal conditioning
Communication interfaces as I2C, SPI
Maybe to program a quad- or hex-copter using calman filters
All that is within a PSoC.
Even though PSOC 1 an older proprietary core, 4 MIPS, it has more varied analog
resources than PSOC 4 (33 MIPS), and has pricing in the range of $ 1 - $ 2 for low
PSOC 1 has hi res A/D, sw cap filters, larger array of offerings in digital
and analog block count, CyFi support, powerline, INAMP, DTMF, PGA......
PSOC 4 much better core, cortex, better tool, more flexible routability, better SAR for
fast A/D, timers and counters more flexible, better reference, less overall analog,
32 bit single cycle multiplier........
You have to set datasheets down side by side to get a feel for the differences.
Both families still very much in play.
The one and only downgrade for PSoC1 is that you need an ICE (some $100) to get debugging capabilities. So not quite easy to learn with.
Open a new thread for a quad-copter and start with AHRS with a common algorithm instead of calman. Let's see what happens.
I must admit, the orginal goal of teaching students, I would stick with Creator and
PSOC 3/4/5. GUI tools because increasing abstraction from HW layers overall
more important in todays engineering space.
Because of Verilog in the tool, specialized HW can be created, while still handling
most of the design at the GUI abstracted level.
As far as costs, you can't beat a $ 4.00 simple PSOC 4 board coupled with a proto
block, or the $ 25 pioneer board where you get two processors to play with, just
enough HW, and Arduino compatibility, like a simple display ( < $ 10 for a simple
2 x 16 LCD off ebay).
http://www.cypress.com/?rid=77780 Pioneer Board
As you say, if you are teaching students and your goal is to make them understand the architecture of the micro and why that particular ISA, you have no option but to teach them assembly.
They can learn simultaneously other high level languages, but assembly is a must.
For freshers, the academia stills considers the 8051 as the starting point. It is indeed very easy to grasp and still in use today.
As soon as we received our PSoC 3 kits (last week) I searched for a "full assembly program". I only found this post.
I have finally managed to put a led blinking in assembly, but I still have a long way to go to make it pure assembly. The "simplest thing" was to place the pin in TopDesign and map it using the Creator to P6.2.
Then I have created a a51 file where I defined the led_blink function:
_LEDBLINK SEGMENT CODE
ORL A,#04H ; P6.2 controlled by SFRPRT6DR
;.... more code
I still require the main.c where I have defined the led_blink prototype void led_blink(void); and call the assembly function.
I will post again as soon as I can do a pure assembly project ...
I am afraid that the assembly quest is already settled. Samwalsh has choosen a PSoC 4 which has got an ARM M0 core which is definitively more modern than a PSoC3's 8051 core. I would suggest you to get hands on a PSoC4 Pioneer kit and use your knowledge of PSoCs for designs that are quite too small for a PSoC3
I do work with PSoC 4 and 5. I also work with ARM processors and Xilinx (ARM cores insides).
It is not only me that thinks that learning 8051 brings adavntages to students. It is the Academia.
8051 was introduced in 1980, and its architecture reflects the knowledge
at that time. It is asymmetric in its addressing for starters, ech. Its efficiency
from almost any viewpoint, use of silicon, microcode, compiler complexity, non
unified, cost, reflects 1980 and earlier.
But as engineers, we too are subject to the change resistant gene in all off us.
Like the EEs who had to adapt from vacuum tubes to transistors, some made the
adaptation, some did not.
If a school is teaching FPGA and ASIC, then it ought at minimum be working with
a technology of the 2000's, not stuff out of the last century. The 8051 has seen its
day. Because we can put an 8051 core, or for that matter a 4004 core, on a chip
does not mean that we should.
it is not a matter of resistance to chance but rather to choose the right tool for the job. In Academia the goal is not to learn to use this or that particular device (as most probably there will be better devices when the student is out of school ), but rather to get the basic concepts you need to use any device out there. For that asembly is the way to go and the 8051 is still the easier core to use with a lot of resources available with little to no distracting features that could get in the way.
I think I have to add my 2 ct:
When you teach a spoken language, you do not choose Aramaic language (which was spoken in the time of Christ's birth), but you choose a today-spoken, well known language (except when teaching latin or ancient greece). The benefit from this is: you will be able to talk and practice what you have learnt.
For the way to introduce assembly language it will not be a requirement to have the COMPLETE project written in asm, but having a subroutine will introduce the very first asm-instruction: RET. The ARM asm is more complicated than the 8051 asm? Yes, you might have to push 15 registers on stack and not only 4. Of more3 interest is "What is a stack, what is a stackpointer?" which has the very same explanation in both worlds (Except the fact that the 8051 stack is very poor 256 bytes deep). Which linkage is more complicate: ARM or 8051? Which code is (nearly intrinsinc) reentrant, ARM or 8051. Remember that the goal is not to learn EVERY assembly instruction, but to learn assembly.
BTW: During my education (which was in 1974) assembly was the 3rd language we learnt, after FORTRAN and PL1 and it was a "good" one compared to the 8051, it was an IBM, but when we swallowed that, it was easy for us to program PDP or the later Z80 in assembly. It is always easier to apply a reduced part of what you have learnt than to expand the basics every time you get something new to handle with.
I think we are talking about completelly different kinds of courses. You know, in university courses you often get taught using asm rather than taught asm.
Please note that the first part of your email is not 100% correct, since in terms of efficiency metrics the "modern" 8051 cores are miles better than the original and please remember that it is an open core (have a look to Enocean).
In my particular case I do not think this issue related with the resistance gene (my view anyway), in more advanced courses students deal with TrustZone and Hibrid Hypervisors.
I do agree with Bob when he points out that we do not need a complete project in assembly. I only find it helpfull. Just a little provocation, are we going to tech a baby to run ... or should he start by walking? 😛
My goal with PSoC 3 dev kit is to teach a simple archictecture and assembly language, move to C language, introduce the basics of Verilog. Furthermore it will be helpful to see very simple hardware tasks running parallel with the code and add a little bit of analog to the mix. Granted ... I could achieve the same with PSoC 4.
Thanks for the discussion!
I come from an experience where we discussed the non unified architecture
of the 8051 when it was introduced, and how unfortunate that was. All in the context
of other processors as well and their limitations in architecture. I even had the fortunate,
or unfortunate experiecne, of working with processors with non linear address spaces, ech,
NSC early COPS to be exact. In generalall these architectures complicated asembly language
programming, introducing exceptions and limits of what HW could be manipulated by what
instruction........I also know from having represented many vendors from the early 80's going
forward, that enhancements were done, and then most of those same vendors over time
dropped the805x product line.Reasons varied, but almost always due to lack of competitive
cost/performance. The word was out. Designers were moving to uniform memory mapped
architectures. And still largely ASM programming.
On another point I polled a number of companies, specifically EE's I was supporting,
late 2000's, what % of them were doing assembly vs other C like language,
and found that time to market was principal driver, hence langauges that remove one
from HW. more prewritten API support, one or more levels removed from bit banging,
increasingly importent. Not to say ASM not worthwhile, its still importent to teach, but
reduced focus. The key areas where it still matters are consumer type designs where
every millicent counts and monthly product shipments exceed giga units/ hour, like medical
disposables, RFID......Even I think C sucks, rigid typing, string contortions w/o additional
librbary support, a pox on design thruput. But then thats a discussion for another day.
In closing of you look at Pioneer board, its has a M0 and M3 core on it, and both can be
debugged, and generally programmed seperately as well. It's Arduino compatible, so
from simple stuff to imagination exploration all in a $ 25 board. make the two processors
talk to each other, use one as a slave, test out various com schemes, high level analog
and DSP to simple stuff. Good for beginning to advanced student.