NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Experiment 5

part 1:
Period/ Frequency Meter
using Timer1 and Module
CCP1 in Cap-ture Mode
---
ISIS:
pin 25 : to virtual terminal

RC0:connected with signal generator (sin)
then connected to osclliscope (pin A)

the other pin in signal generator (squ)
connected to gnd.
-----
code :
void main(void)
{
unsigned int t1, t2, Nticks;
float Tmc, period, freq;
OSCCON=0x60;
ADCON1=0xF;
serial_init(25,1);
CCP1CON=0x05;
TRISC2=1;
T3CON=0x40;
CCP1IF=0;
TMR3L=TMR3H=0;
while(CCP1IF==0);
TMR3ON=1;
t1=(CCPR1H<<8)+CCPR1L;
CCP1IF=0;
while(CCP1IF==0);
TMR3ON=0;
CCP1CON=0x0;
t2=(CCPR1H<<8)+CCPR1L;
Nticks=t2-t1;
Tmc=(4.0/4);
period=Tmc*Nticks;
freq=1e6/period;
printf("t1=%d,t2=%d, Nticks=%d, Tmc=%g us, period=%g us, freq=%g Hzrn",
t1, t2, Nticks, Tmc, period, freq);
while(1);
}
#############
part 2:
Square Wave Generation using
Timer3 and Module CCP2 in
Com-pare Mode
-------
ISIS: same in part1
--------
code:
#include "ee470.h"
void main(void)
{
OSCCON=0x70;// 8 MHz internal OSC
ADCON1=0xF; // all digital
CCP1CON=0x02; // toggle RC2 on compare match
T3CON=0x0; // use Timer1 with capture/compare
T1CON=0x0; // pre=1
TRISC2=0;
CCPR1H=40000>>8; // =0x9c
CCPR1L=(400000<<8)>>8; // = 0x40
TMR1ON=1;
while(1)
{
CCP1IF=0;
TMR1H=TMR1L=0;
while(CCP1IF==0);
}
}
############
part3:Square Wave Generation
using Module CCP1 in PWM Mode

*Generate a square wave having a
frequency of 1.5KHz and a duty
cycle of 75% using module CCP1
running in PWM mode. Take fosc=1MHz
-----
ISIS:
RA0: 10K to VCC then switch to gnd
pin17 :to osclliscope (pin A)
RB0:10k to led to gnd
----
code :
#include "ee470.h"
void main(void)
{
OSCCON=0x70;
ADCON1=0xF;
T2CON=0x01;
PR2=199;
CCPR1L=(unsigned char) 199*0.75;
TRISC2=0;
TRISA0=1;
TRISB0=0;
CCP1CON=0x1C;
TMR2=0;
TMR2ON=1;
while(1)
{
RB0=RA0;
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.