RenesasT
Full Member level 2
- Joined
- Mar 11, 2016
- Messages
- 149
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 16
- Activity points
- 1,330
Now I wanted to use the same pin which should accept pwm and according to the duty cycle of i/p pwm it should vary the duty cycle of o/p Pwm.
In case I am using analog then it should work as analog control and if I am using PWM then it should work as PWM control.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 sbit Led at GP2_bit; sbit Led_Direction at TRISIO2_bit; unsigned int pwm_duty = 0, old_pwm_duty = 256; void Configure_Pin_As_Analog_Input() { Led_Direction = 1; ADCON0 = 0x80; ANSEL = 0x54; Delay_ms(2); } void Configure_Pin_As_Digital_Output() { Led_Direction = 0; ANSEL = 0x50; } void main() { CMCON0 = 0x07; ANSEL = 0x00; TRISIO = 0x00; GPIO = 0x00; Delay_ms(100); PWM1_Init(2000); PWM1_Set_Duty(0); PWM1_Start(); while(1) { Configure_Pin_As_Analog_Input(); pwm_duty = ADC_Read(2) >> 2; if(old_pwm_duty != pwm_duty) { PWM1_Set_Duty(255 - (unsigned short)(pwm_duty)); old_pwm_duty = pwm_duty; } Configure_Pin_As_Digital_Output(); Delay_ms(100); } }
Suppose I am using i/p PWM signal at microcontrollers pin and now I wanted to o/p PWM at other microcontroller pin. If duty of i/p pwm is changed then duty of o/p pwm should changed.
Delay_ms(100);
Delay_ms(10);
...According to my PIC cannot output a PWM of 100 Hz.
in datasheet of ATtiny10 it is mentioned that it has one timer.
Does my project is possible.?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?