BLINK LED WITH PWM8

A catchall for PSoC Mixed-Signal Array (microcontroller) discussions not captured by the other forums.

Moderator: ericb

Re: BLINK LED WITH PWM8

Postby car1365 » Thu Dec 15, 2011 4:53 am

OH!!!I've proved what you told me, and the LED blinks at last!! :D
but it just blinks very fast, I think this doesn't blink at 1.4HZ...

Anyway, I'd like to know why!can you explain me the difference between P1_7 and P2_0??how did you know??and why I have to remove the LCD??

Thank U!!!

Car
car1365
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Wed Nov 30, 2011 10:07 am

Re: BLINK LED WITH PWM8

Postby bobmarlowe » Thu Dec 15, 2011 7:25 am

I've got the same kit and was playing around with it for some time, so I knew that port 2 was used by the LCD-module (except P2{7]).
Sorry that it took so long for me to realize (and to ask you) that you are using a kit. 1 hour ago I set it up and programmed your project (changed ports!) into, and it worked.

The specs for the IMO (Internal Main Oscillator) say 24MHz and +- 50% or so. As such it may be that it runs too fast.

Now you could carefully re-insert the LCD-module again and check that there is NO internal or external connection to any pin of port2.
In Designer drop a LCD-Component onto your chip (you will not see it) configure it for Port2 and add some lines into your main.c:

LCD_1_Start();
LCD_1_Position(0,0);
LCD_1_PrCString("Blink Example");
LCD_1_Position(1,0);
LCD_1_PrCString("by Car");

Oh, yes, did you activate the C-Compiler ? Click Tools-options-build-compiler here you select the IMAGECRAFT C-Compiler which will make many things easier! (That's the reason why it was invented!)

Have fun
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: BLINK LED WITH PWM8

Postby graaja » Thu Dec 15, 2011 5:11 pm

bobmarlowe wrote:The specs for the IMO (Internal Main Oscillator) say 24MHz and +- 50% or so. As such it may be that it runs too fast.

A correction. The IMO has a tolerance of 2.5%. The ILO is the one that has a tolerance of 50%
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3084
Joined: Thu Dec 18, 2003 4:35 pm
Website: http://www.planetpsoc.com
Location: India

Re: BLINK LED WITH PWM8

Postby bobmarlowe » Fri Dec 16, 2011 2:01 am

Oops, sorry.
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: BLINK LED WITH PWM8

Postby car1365 » Fri Dec 16, 2011 3:23 am

ok, just one thing...I don't use C, I'm using Assembler, because the teachers told me that is better...so...

and another question, if the LED blinks so fast, what can I do? do you have any idea??

thank you again!!

Car
car1365
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Wed Nov 30, 2011 10:07 am

Re: BLINK LED WITH PWM8

Postby car1365 » Fri Dec 16, 2011 4:25 am

forget that I've said!!
The Led blinks perfectly!!!

Thank U again everybody!!!You've helped me so much!!!

Car
car1365
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Wed Nov 30, 2011 10:07 am

Re: BLINK LED WITH PWM8

Postby danadak » Fri Dec 16, 2011 4:57 am

Assembler is better -

1) For learning hardware in depth.
2) Code size (very dependent on writers depth of knowledge).
3) Speed (very dependent on writers depth of knowledge).
4) Memory management more flexible, especially when close to device limits.

Assembler is worse -

1) Portability, ability for someone else to read or use your code.
2) Time to completion of code writing, C is generally faster
to write and debug.

I am sure I would get many arguments, but the above generally accepted.

Here is one viewpoint -

http://www.kwantlen.ca/science/physics/faculty/dpeirce/notes/c18/C_assembly.html

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: BLINK LED WITH PWM8

Postby bobmarlowe » Fri Dec 16, 2011 5:34 am

There was an investigation of correlation between Number of keystrokes to solve a given programming problem for different languages.
Assembly gained the first place (maximum Keystrokes)
followed by COBOL :D (not astonishingly for any COBOL programmer: "Divide divisor into divident giving quotient remainder MyModulo" is normal/legal COBOL)

You SHOULD know assembly (rather: a few assemblies, they are all different), you SHOULD know about addressing modes and you SHOULD know about memory models.
You MUST know what registers are (for), you MUST know what an interrupt is and you MUST know what flags are, how to set, clear and question for them.
You ought to know a "Problem-oriented programming language", preferrably C.

To my students I say at the beginning of the programming-lessons:
PASCAL assumes you to be a dumb, silly programmer and if you are not telling precisely what you want, you'll get a compile-time-error.
C assumes you are a geneous programmer and you know exactly what kind of rubbish you just wrote down, and you'll get a system-crash.
ASSEMBLY does what you wrote and you'll get... nothing

I know ASSEMBLIes, C, PASCAL, FORTRAN, ALGOL, COBOL, PL1, PL-M,... and yes, I know BASIC. (BASIC starts with "Bah!" and ends on "sick!").
Danadac, there are free(!!) PASCAL compilers (Lazarus) which are on the PC-side pretty good to work with, there is no need to use any basics visual or unvisual.

Happy coding
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: BLINK LED WITH PWM8

Postby slandrum » Fri Dec 16, 2011 6:03 am

Whether assembler is better than compiler also depends a lot on the CPU you are targeting.

The M8C (the CPU core used in the PSoC1 devices) is extremely limited, has very few CPU general purpose registers, has limited code space, has limited register size, has separate instructions for accessing RAM or ROM, has an unusual paging structure for RAM, etc. All of these things make it unfriendly to compilers, and compilers will generally generate inefficient code for the processor. I would personally never use a C compiler for my PSoC1 projects, but a lot of people do.

A modern processor like anything in the ARM family has a lot of general purpose registers, has a single memory space for everything, the registers are wide, and in general the processor architecture is very compiler friendly. With a good optimizing compiler, you would often be hard pressed to hand code more efficient assembler code than the compiler can generate, and you are generally much better off leaving that to the compiler.

In either case, your algorithm and general code structure will be far more important than whether you are writing in assembler or C or some other higher level language.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: BLINK LED WITH PWM8

Postby bobmarlowe » Fri Dec 16, 2011 7:21 am

@Slandrum
I wrote a Task-context-swith that enables different independent tasks to run simultaneously (up to ~20) on a PSoC1(29466 ) using about 8k Prom.
I would never have the slightest idea to write that in assembly. Did you ever get near the limits of Ram or Rom in one of your projects?
The major factor of a project is "Costs" and thus of course the time for software - design, coding, testing and integration. Re-usable code in high-level languages reduces the afford of the first three items, design coding and testing. As long as I am not forced to use ASM I would stick to C. And -last, not least- every programmer knows C, but only a few know M8C-Asm.
Although I'm not really happy with the C-implementation in PSoC3 I would never write a Project in 8051-Asm (Although I know it) but use C.

Happy coder
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: BLINK LED WITH PWM8

Postby slandrum » Fri Dec 16, 2011 8:00 am

The 29xxx parts are the biggest and most expensive of the PSoC1.

I wasn't running out of memory on the 29xxx parts when I used them, but always was running out on the 27xxx or even worse on the 24xxx parts.

4K flash ROM with 256 bytes of RAM is not much to work with, and implementing a task handler would not be appropriate on those parts. Also, the PSoC1 is slow enough that I barely had time for my interrupt handlers, and certainly could not afford any overhead for task switching. Task handling would have been completely inappropriate for the projects I was working on, even for the projects that used the 29xxx parts.

My projects almost always push the capabilities of the system beyond the expected limits. This was not going to be possible if I was writing my code in C.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: BLINK LED WITH PWM8

Postby nagarajan » Tue Apr 01, 2014 4:29 am

Thanks.. now i got the pwm output, before that i made mistake now i rectifies it through this forums.
nagarajan
Newbie
Newbie
 
Posts: 1
Joined: Tue Apr 01, 2014 4:09 am


Return to “%s” PSoC1 General

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron