BLINK LED WITH PWM8

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

Moderator: ericb

BLINK LED WITH PWM8

Postby car1365 » Wed Nov 30, 2011 12:20 pm

hello!can someone help me please?!
I'm new in a PSoC's world, and I'm a little lose...
I'm making an example wich is in the PSoC1 guide. I want a LED blink using PWM8; the guide says:
"implementation: the clock dividers VC1, VC2, and VC3 are used to divide the 22 MHZ system clock by 16, 16 and 256, respectivity. The reulting 366 Hz clock is used as the input to an 8-bit PWM. This in turn produces an LED blink of 1.4 HZ."
this is the theory but I don't know how can I do these with the psoc designer software...
I have the asm code and I konow that it's correct, but I don't know what values of VC1 VC2 and VC3, I have to use...


Thanks so much everyone!!
car1365
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Wed Nov 30, 2011 10:07 am

Re: BLINK LED WITH PWM8

Postby danadak » Wed Nov 30, 2011 2:44 pm

I want a LED blink using PWM8; the guide says:
"implementation: the clock dividers VC1, VC2, and VC3 are used to divide the 22 MHZ system clock by 16, 16 and 256, respectivity. The resulting 366 Hz clock is used as the input to an 8-bit PWM. This in turn produces an LED blink of 1.4 HZ."


1) Confirm the dividers produce 366 Hz. First the clock is nominally 24 Mhz, not 22. So we have 24 Mhz / 16 / 16 / 256 = 366.2...Hz.
Nominal, PSOC clock accuracy has to be taken into account under the worst case.

2) We need to get to 1.4 Hz from 366.2, so N =~ 366.2 / 1.4 =~ 261.57.... We have a problem Houston, our 8 bit divider can only
divide by 256, so our blink rate would be 366.2 / 256 =~ 1.43 Hz. Will anyone know we fudged ? Just the Oscope and F / Period counter.
Or we use a 16 bit timer. Note, reading Timer datasheet you load period register with 255, but it divides with N + 1 ( 255 + 1).

3) We set up our divider, PWM, period for 255, compare value ~ 1/2 that, enable and start timer, and route Timer compare output to
a pin.

4) Drive LED to ground (LED tied series from Vdd to Rlimit to pin, driving current to ground, PSOC has greater capability, LED brighter.

These parameters are set up in global window of Designer, and the PWM module window.

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 » Wed Nov 30, 2011 11:10 pm

In the Chip-View there is a window named "Global Resources"
There you fix a lot of global parameters for your project. Select
5V / 24 MHz
VC1=Sysxlk/16
VC2=VC1/16
VC3=VC2/256
with the corresponding source and divider.

Now you have a VC3 clock running with ~366.2Hz

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 car1365 » Thu Dec 01, 2011 2:48 am

Thank U so much for the information, but I've got a due yet, in the "global resource"window, appear VC1=Sysclk/N, in VALUE, do you have to put 16??
I put the values in the global resource window like these:
VC1=Sysclk/N 16
VC2=VC1/N 16
VC3 divider 255

but the led doesn't blink....
sorry for my ignoraNCE..I'm new in this world :oops:
thank U so much
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 01, 2011 3:34 am

Well, I think, you should post your complete Project, maybe the routing for the pin is not correct or something else is not right. Zip your Project, I'll have a look at it.
When I started with PSoCs I made a lot of errors as well, so don't be dissapointed.
Do you use an ICE-Cube (or do you own one?)

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 Blackfin » Thu Dec 01, 2011 4:01 am

bobmarlowe wrote:Well, I think, you should post your complete Project...


+1
Blackfin
The Big Cheese
The Big Cheese
 
Posts: 284
Joined: Thu Jun 07, 2007 10:28 am

Re: BLINK LED WITH PWM8

Postby car1365 » Mon Dec 12, 2011 3:54 am

Good morning!I'm sorry to be late...

I don't know if I've got the correct values of the parameters of PWM8:

Clock: VC1
Enable: high
compareOut:Row_0_Output_0
TerminalCountOut: None
Period: 255
PulseWidth:85
CompareType: Less than
Interrupt type: terminal count
ClockSync: Sync to SysClk
InvertEnable: Normal

And the global resources:

PowerSetting: 24MHz/5.0V
CPUClock: Sysclk/8
32K_Select:Internal
PLL_Mode:Disable
Sleep timer:512_HZ
VC1=Sysclk/N: 16
VC2=VC1/N:16
VC3 source: VC2
VC3 divider: 255
Sysclk Source: internal
Sysclk *2 Disable: No
AnalogPower :SC On/ref Low
RefMux: (Vdd/2)+/-BandGap
AGndBypass:Disable
Op_AmpBias: Low
A_Buff_Power:Low
SwitchModePump=OFF
tripVoltage[LVD[SMP]]:4.8v[5.00v]
lvdtROTTLE bACK:dISABLE
WhatchDog Enable:Disable


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

Re: BLINK LED WITH PWM8

Postby bobmarlowe » Mon Dec 12, 2011 4:03 am

Hi carl,
at first sight everything seems to be O.K.

As a matter of fact, the LED (when connected to the PWM's output) will blink at a rate of 5,9 KHz with a duty-cycle of ~1/3. Is that what you want?

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 Blackfin » Mon Dec 12, 2011 4:17 am

car1365 wrote:Good morning!I'm sorry to be late...

I don't know if I've got the correct values of the parameters of PWM8:

Clock: VC1 ...


Don't you want VC3 as the clock source here?
Blackfin
The Big Cheese
The Big Cheese
 
Posts: 284
Joined: Thu Jun 07, 2007 10:28 am

Re: BLINK LED WITH PWM8

Postby car1365 » Mon Dec 12, 2011 4:30 am

Hi!
No exactly...The LED shuld blink with period of 1.4Hz.
The problem is when I test these, the LED don't blink. It just set up, but no blink; and I think, the problem is the frecuency is so high, but I don?t know how to solve it.

thank U 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 bobmarlowe » Mon Dec 12, 2011 4:38 am

What would help us to help you is: zip and post your project files, then we can have a look at it.

Happy Zipping :wink:
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 » Mon Dec 12, 2011 8:03 am

ok!!
Here you Have it.
:)
Thanks!!
Attachments
ASM_Example_Blink_LED.rar
(156.03 KiB) Downloaded 238 times
car1365
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Wed Nov 30, 2011 10:07 am

Re: BLINK LED WITH PWM8

Postby slandrum » Mon Dec 12, 2011 8:32 am

The configuration you showed (I haven't opened your project) would have the LED blink at a rate of 5859Hz, which you won't see as blinking at all. You could hook up an oscilloscope to monitor it, though.

If you wanted the LED to blink at 1.4Hz, you need to set its clock to VC3, not VC1.
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 » Mon Dec 12, 2011 8:49 am

Oh, my dear!!!
I said "Zip" it, not "Raw". I will not download a program when my OS (Win) has it for free.

Sorry cannot open.
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 bobmarlowe » Mon Dec 12, 2011 12:12 pm

I got it opened (Downloaded winraw, installed it unzipped your archive, de-installed winraw, rebooted my pc... please next time a ZIP-archive)

Just as a few others posted, you should change the PWM's clock to VC3, that should do the trick.

I have some hints for you:
1st: You should update your version of your Designer to the latest
2nd: there is a free C-Compiler available, you just have to register for it. Using C gives you the opportunity to use (parts of) your programs on PSoC3 or 5. This is far reasier to program and to de-bug than using the M8C-assembly especially when the programs grow larger.
3rd: You enabled the interrupt but you didn't program an interrupt-routine which is a bit complicated. Have a look into the manuals.

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 graaja » Tue Dec 13, 2011 3:32 am

Use the following combination.

1. Set VC1 to 16
2. Set VC3 source to VC1
3. Set VC3 divider to 256
4. Place a PWM16 instead of PWM8
5. Set PWM clock to VC3
6. Set Period to 4184
7. Set PulseWidth to 2092

This will produce a 1.4Hz output at 50% duty cycle.
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 car1365 » Wed Dec 14, 2011 3:04 am

Thank U everybody!!
I've changed the clock of PWM and set to VC3, how you told me...but the problem persist... I don't know why :?

do you have an other idea??

I'm really desperate!!

graaja, your suggestion maybe great, but I need PWM8 not PWM16, but thank U anyway...
car1365
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 17
Joined: Wed Nov 30, 2011 10:07 am

Re: BLINK LED WITH PWM8

Postby bobmarlowe » Wed Dec 14, 2011 8:35 am

A question: what board do you use? is it a kit, an evaluation board or a self-made one?
Please post exact type.
You are using the device CY28466-pxi, so it is probable you have got the kit with a LCD on it. Be aware that port2 is used by this module, better use port1 for your LED.

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 » Wed Dec 14, 2011 1:54 pm

I've got a kit, exactly, CY3210-PSoCEVAL 1-U, because I'm working at university...
I`m using the port 2 to the LED because i'm following a guide that the kit has; but it doesn't specify the parameter's values of PWM8; just the implementation and the harward conexion.

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 » Wed Dec 14, 2011 2:56 pm

And you did remove the LCD and jumpered a wire from port 2[0] to one of the LEDs?
Better try P1[7] to the LED

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


Return to “%s” PSoC1 General

Who is online

Users browsing this forum: No registered users and 5 guests

cron