sanjubluerock3
Full Member level 3
- Joined
- Sep 29, 2008
- Messages
- 174
- Helped
- 21
- Reputation
- 42
- Reaction score
- 18
- Trophy points
- 1,298
- Location
- Bengaluru, India
- Activity points
- 2,080
here we go...
this how u going to connect mclr
Hi,
Vee is for adjusting the contrast of the LCD. Connect a pot to the pin like this and adjust it until you see something (also, you forgot to connect MCLR to +5v):
Hope this helps.
Tahmid.
Hi,
Vee is for adjusting the contrast of the LCD. Connect a pot to the pin like this and adjust it until you see something (also, you forgot to connect MCLR to +5v):
Hope this helps.
Tahmid.
ISR
1. Check if interrupt is associated with PWM
2. Update CCPR1L with required value for required duty cycle
3. Clear flag
4. Return
end ISR
main code block:
* Initialize everything required, eg ports, port directions, timer (TMR2 - for PWM), PWM (CCP1CON, CCPR1L)
1. Set PWM period through PR2
2. Set PWM duty cycle through CCPR1L
3. Make sure you initialized TMR2 and CCP1CON properly
4. Enable CCP1 interrupt
5. Set GIE
6. Set PEIE
7. Start TMR2
8. Do LCD stuff
end main code block
Hi,
Have the LCD working in the main code and run the PWM through interrupts. Like:
Code:ISR 1. Check if interrupt is associated with PWM 2. Update CCPR1L with required value for required duty cycle 3. Clear flag 4. Return end ISR main code block: * Initialize everything required, eg ports, port directions, timer (TMR2 - for PWM), PWM (CCP1CON, CCPR1L) 1. Set PWM period through PR2 2. Set PWM duty cycle through CCPR1L 3. Make sure you initialized TMR2 and CCP1CON properly 4. Enable CCP1 interrupt 5. Set GIE 6. Set PEIE 7. Start TMR2 8. Do LCD stuff end main code block
I hope you can use this bit to write the code. If you get stuck, I can help you with the coding.
Hope this helps.
Tahmid.
---------- Post added at 16:42 ---------- Previous post was at 16:41 ----------
You can use the PWM library which would make everything much easier. I'll try to post a sample code later.
---------- Post added at 16:43 ---------- Previous post was at 16:42 ----------
You can also achieve this without interrupt. I'll see if I can post a code to show how.
void main()
{
while(1)
{
TRISB=0;
PORTB=0b10000000; //Motor moves in one direction
Delay_ms(10000);
PORTB=0b01000000; //Motor moves in the opposite direction
Delay_ms(10000);
}
}
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?