PIC Simple Signal Generator
PIC Simple Signal Generator
Remark: Capable of generating repeating or non-repeating electronic signals with the use
of Pulse Width Modulation.
1) Draw a high-level block diagram to show the inputs/output devices and any other
modules connected with the microcontroller. Briefly explain the diagram.
Power Supply
PIC18F4550
PRESET LCD
Microcontroller
PIC18F4550 controller has in-built 10-bit PWM module known as CCP module. CCP stands for
Capture/Compare/PWM. There are two CCP modules (CCP1 and CCP2), this means we can
generate two PWM signals on two different pins.
• An analog input should be given to the microcontroller. For that, a keypad is used.
• PIC18F4550 has 13 channels which mean 13 analog input signals can be converted
simultaneously using the module. 8 clock inputs which can be chosen as we need, are
available for conversion and the module can be configured in auto triggering mode.
• In PIC18F4550, only Timer2 can be used for PWM generation. TMR2 is a 16-bit Timer2
register which is used to hold the count. (All PWM modules in a PIC Microcontroller
uses Timer 2 for its operation, so you cannot set different frequencies for different PWM
modules)
• LCD displays the necessary PWM waveforms and also the relevant details.
• Power is supplied through a regulated power supply.
3) Briefly explain the communication modes you will be using in your system.
• LCD communicates with parallel communication mode with the microcontroller.
• PIC18F4550 has an inbuilt EUSART (Enhanced USART).
4) State if you are using Analog to Digital or Digital to Analog converters in your system.
State why? If you are not using AD converters, briefly explain why.
There is no any use of converters in this design as an inbuilt ADC module is there in the
microcontroller. Therefore, we can give the input of preset directly into the analog pins. And also
the LCD displays the digital value 1 as 1V and 0 as 0V. Therefore, any DAC is not needed in the
design.
#include<pic.h>
#define __XTAL_FREQ_
void main() {
TRISC = 0;
PORTC = 0;
TRISA = 0X0f;
PORTA = 0;
TRISB =0XFF;//PUSH BUTTON
T2CON = 0X04;
CCP1CON = 0X0C;
PR2 = 99;
TMR2 = 0;
ADCON0 = 0X41;
ADCON1 = 0X0E;
OPTION_REG = 7;
TMR0 = 0;
INTEDG = 1;
INTE = 1;
GIE = 1;
while (1) {
if (T0IF == 1) {
GO = 1;
while (GO == 1) {
}
CCPR1L = ADRESH;
ADRESL = ADRESL >> 2;
CCP1CON = CCP1CON & 0X0F;
CCP1CON = CCP1CON + ADRESL;
T0IF = 0;
}
}
}
T2CON = 0X04;
CCP1CON = 0X0C;
CCPR1L = 0XCD;
CCPR1H = 0X00;
}
INTF = 0;
}
7) Write an assembly program to generate the required delay as a separate program using
timers.
org 0x00
goto start