Professional Documents
Culture Documents
2019 VB2140e
3. Write a program using C language for odd number of LEDs at PortB (using LEDs in Figure 1)
every 1 second using Delay function below.
void Delay(unsigned int ms)
{
unsigned char i;
while(ms){
ms--;
i=122;
while(i) i--;
}
Figure 1
4. PIC 18F452 has ability for external as well as internal clock source but we are using Timer0
with internal clock (Timer mode). Calculate the time delay of 1 sec using 20MHz crystal
oscillator with PIC microcontroller to make circular right shift at PortB (using LEDs, refer
Figure 1).
5. Initialize C program to generate to generate PWM based on information given below:
a) XTAL=4MHz, 1kHz PWM frequency, 1:4 prescaler, 50% duty cycle.
2
Figure 2
7. A varying signal of 0-5V is applied in the AN0 pin of PIC18F4550 and the analog value is
converted to the corresponding digital value. Write a C program for the ADC. (remarks:
The analog voltage is generated and varied using a potentiometer. Refer Figure 3)