-
1. Re: Simple PWM
riko.husin Feb 10, 2013 11:53 AM (in response to riko.husin)and how to use timer for it ?
in MCS51 :
void delay_us (void) //100us delay on 12Mhz
{
TH0=0;
TL0=0;
TH0 = 0xFF;
TL0 = 0x37;
TR0 = 1;
while(!TF0);
TR0 = 0;
TF0 = 0;
return;
}How can I create this on Cypress PSOC 1 ?
thanks
-
2. Re: Simple PWM
user_1377889 Feb 10, 2013 12:09 PM (in response to riko.husin)Easiest would be to use a PWM - Component and configure it accordingly. Have a look at the PWM's datasheet.
The way you showed in your example differs a bit from the way PSoCs work: Usually you do not need to access ports or pins directly, there are many pre-defined components: timers, PWM, counter, interfaces and you just have to configure them at design-time and start them with an API at run-time preferrably in c-language.
Bob
-
3. Re: Simple PWM
user_14586677 Feb 10, 2013 12:48 PM (in response to riko.husin)Some possibilities(besides the basic PWM module) -
http://www.cypress.com/?rID=2801
http://www.planetpsoc.com/component/content/article/71-prs-pwm.html
and the basic modules in Designer IDE (see lower right) -
Regards, Dana.
-
4. Re: Simple PWM
user_14586677 Feb 10, 2013 12:50 PM (in response to riko.husin)Pic attached.
Regards, Dana.
-
PSOC 1 PWMs and Timers.jpg 290.7 K
-
-
5. Re: Simple PWM
riko.husin Feb 10, 2013 9:10 PM (in response to riko.husin)I have a chip level diagram as in the picture..
How can I connect the PWM ? for pinout, for example I wanna use P0.4 as an output to my motor.
Please find my capture attached
-
pwm.jpg 497.9 K
-
-
6. Re: Simple PWM
rajivb_36 Feb 10, 2013 9:39 PM (in response to riko.husin)In the parameters window of PWM8 user module, set the "compare out" as Row0_Output0. Then, click on LUT on that row and click on the buffer which connects to GlobalOutEven4 (GOE 4). Then click on globalOutEven4 line and select the "pin" as P0[4].
Please see attached PDF file for example.
-Rajiv Badiger
-
Digital routing.pdf 818.4 K
-
-
7. Re: Simple PWM
arvindk_86 Feb 11, 2013 1:49 AM (in response to riko.husin)The simplest way to see a PWM signal on your pin is using the PWM usermodule.
Place it in your project, configure the signal timing/duty using the usermodule parameters window (refer to the PWM datasheet for info on this; right click on the PWM block -> Datasheet)
Configure output as Rajiv mentioned; easier way is to do it graphically:
Hold Shift key and click on the "CompareOut" terminal, then click on the Pin of your choice.
Only code that you need to add in your main.c is PWM8_Start(); (PWM8 is the name of the usermodule, change accordingly)
Regards,
Arvind
-
8. Re: Simple PWM
riko.husin Feb 14, 2013 7:47 PM (in response to riko.husin)Ok, I'll try and get back to you guys later,
thanks for helping
-
-
-
11. Re: Simple PWM
user_14586677 Feb 14, 2013 9:21 PM (in response to riko.husin)Click on LUT at end of ROW out, RO0(0) and this pops up
Regards, Dana.
-
12. Re: Simple PWM
user_14586677 Feb 14, 2013 9:26 PM (in response to riko.husin)Here are basic short videos to learn how to do HW routing and
a lot of other stuff for PSOC 1 -
http://www.cypress.com/?rID=40543
Regards, Dana.
-
13. Re: Simple PWM
riko.husin Feb 15, 2013 2:50 AM (in response to riko.husin)I tried like in the captured picture, is it right ?
What's the period and pulse width for it ?
thanks
-
pwm3.jpg 427.2 K
-
-
14. Re: Simple PWM
user_14586677 Feb 15, 2013 5:11 AM (in response to riko.husin)From the data sheet (right click component and select data sheet )
TOUT = (PeriodValue+1)/FCLOCK
FOUT = FCLOCK/(PeriodValue+1)
The duty cycle equation also in datasheet.
And you should set a couple more properties. Note in datasheet are API f()
calls you can make to control PWM in software, like set period and dutycycle,
and to start the PWM.
Regards, Dana.