and how to use timer for it ?
in MCS51 :
void delay_us (void) //100us delay on 12Mhz
TH0 = 0xFF;
TL0 = 0x37;
TR0 = 1;
TR0 = 0;
TF0 = 0;
How can I create this on Cypress PSOC 1 ?
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.
Some possibilities(besides the basic PWM module) -
and the basic modules in Designer IDE (see lower right) -
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.
Please see attached PDF file for example.
Digital routing.pdf 818.4 K
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)
Ok, I'll try and get back to you guys later,
thanks for helping
What's "LUT" ?
Click on LUT at end of ROW out, RO0(0) and this pops up
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.