Beruflich Dokumente
Kultur Dokumente
HowtoInterface7SEGwithPIC16F877A
MemberLogin
|
AboutUs
|
BecomeaMember
|
ContactUs
|
Dealership
Search
Home
Products
ProjectKits
Components
Articles
Customers
Forum
Blog
Jobs
Training
MicrocontrollerBoards
DSP/DSCBoards
PowerElectronicsandDrives
CPLD/FPGABoards
AccessoryBoards
0
HowtoInterface7SEGwithPIC16F877A
7SegmentDisplayInterfacingWithPIC16FPrimer
Tags:InterfacingSevenSegmentwithPIC16F877Aprimerboard,CircuitDiagramtoInterface7segmentwith
PIC16F877Aprimerboard,CProgramto7SegmentDisplayusingPIC16F877Aprimerboard,,sevensegment
projectusingpic16f877a,sevensegmentinterfacewithPIC16F877ASEVENSEGMENTInterfacewithPIC
microcontrollers
DownloadSourcecode
Ratethis(Logintoaddarating)
Overallrating
PIC16F/18FPrimerBoard
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
1/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
ThePIC16F/18FPrimerboardisspecificallydesignedtohelpstudentsto
mastertherequiredskillsintheareaofembeddedsystems.Thekitis
designedinsuchwaythatallthepossiblefeaturesofthemicrocontrollerwill
beeasilyusedbythestudents.Thekitsupportsinsystemprogramming(ISP)
whichisdonethroughUSBport.
MicrochipsPIC(PIC16F877A),PIC16F/18FPrimerKitisproposedto
smooththeprogressofdevelopinganddebuggingofvariousdesigns
encompassingofHighspeed8bitMicrocontrollers.
SevenSegmentDisplay
Asevensegmentdisplayisthemostbasicelectronicdisplaydevicethatcan
displaydigitsfrom09.Themostcommonconfigurationhasanarrayofeight
LEDsarrangedinaspecialpatterntodisplaythesedigits.Theyarelaidoutas
asquaredofffigure8.
InterfacingSevenSegmentDisplay
Fig.1showshowtointerfacethesevensegmentswithmicrocontroller.Asevensegmentisgenerally
availableintenpinpackage.WhileeightpinscorrespondtotheeightLEDs,theremainingtwopins(atmiddle)
arecommonandinternallyshorted.Thesesegmentscomeintwoconfigurations,namely,Commoncathode
(CC)andCommonanode(CA).
Fig.1Interfacing7segmenttoMicrocontroller
InterfacingSevenSegmentwithPIC16F877A
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
2/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
WenowwanttodisplayafourdigitnumberinPIC16F/18FPrimerBoardbyusingsevensegmentdisplays.
ThesevensegmentdisplayisconnectedwithPIC16F877Amicrocontroller.
InPIC16f/18FPrimerKit,4nos.ofcommonanodesevensegmentdisplaysarecontrolledbysevensegment
drivers.
PinAssignmentwithPIC16F877A
7SEGDriver PIC16FLINES
7SEG
Display
PORTB.0
PORTB.1
PORTB.2
PORTB.3
PORTB.4
PORTB.5
PORTB.6
DP
PORTB.7
CL1
PORTA.3
CL2
PORTA.2
CL3
PORTA.1
CL4
PORTA.0
Connections
*ConnectPORTBwithJP15viaFRC
Cable.
*JP15isatSevenSegmentSection
Output
*Digitswillbeincrementingfrom0to
9999
CircuitDiagramtoInterface7segmentwithPIC16F877A
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
3/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
SourceCode
TheInterfacingsevensegmentdisplayswithPIC16F877Aprogramisverysimpleandstraightforward,
whichdisplayafourdigitnumberinsevensegmentdisplay.TheCprogramsaredevelopedinMplabsoftware.
HereweareincrementacounteranddisplaythisvalueloadedintosevensegmentdriverinPIC16F/18FPIC
PrimerBoard.
CProgramto7SegmentDisplayusingPIC16F877A
***************************************************************************************
Title:ProgramtoSevenSegmentdisplay
***************************************************************************************
#include<pic.h>//DefinePICRegisters
_CONFIG(0x3f72)//HS,Enable(PWRTE,BOREN),
//Disable(CPD,CP,WDTEN,IncircuitDebugger)
#defineCNTRL_PORTPORTA
#defineDATA_PORTPORTB
voidhex2dec(unsignedchar)
voidsend_seg(unsignedchar,unsignedchar,
unsignedchar,unsignedchar)
voidDelayMs(unsignedint)
unsignedcharx
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
4/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
unsignedcharthou=0,hun=0,ten=0,single=0
unsignedcharCA[10]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}
unsignedcharCC[10]=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}
unsignedcharCA_CNTRL[4]={0x07,0x0b,0x0d,0x0e}
unsignedcharCC_CNTRL[4]={0x08,0x04,0x02,0x01}
unsignedcharn=1
voidmain()
{
unsignedcharnumber
nRBPU=0
TRISB=0x00//PORTBconfiguredasO/P
ADCON1=0x07//ConfigurePORTA&PORTEasDigitalport
TRISA=0x00//PORTAConfiguredasO/P
while(1)
{
if(x==200)
{
x=0
single++//Incrementupto9inunitplace
if(single>9)
{
single=0
ten++//Incrementupto9inTenthplace
if(ten>9)
{
ten=0
hun++//Incrementupto9inHundredthplace
if(hun>9)
{
hun=0
thou++//Incrementupto9inThousandthplace
if(thou>9)
thou=0
}
}
}
}
x++
send_seg(thou,hun,ten,single)
}
}
voidsend_seg(unsignedcharthou,unsignedcharhun,
unsignedcharten,unsignedcharsingle)
{
if(n==1)
{
CNTRL_PORT=CA_CNTRL[0]//EanbleUnitplace7Segment
DATA_PORT=CA[single]//DisplayUnitPlaceNumber
n=2
DelayMs(5)
}
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
5/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
elseif(n==2)
{
CNTRL_PORT=CA_CNTRL[1]//EanbleTenthplace7Segment
DATA_PORT=CA[ten]//DisplayTenthPlaceNumber
n=3
DelayMs(5)
}
elseif(n==3)
{
CNTRL_PORT=CA_CNTRL[2]//EnableHundredthplace7Segment
DATA_PORT=CA[hun]//DisplayHundredthPlaceNumber
n=4
DelayMs(5)
}
elseif(n==4)
{
CNTRL_PORT=CA_CNTRL[3]//EanbleThousandthplace7Segment
DATA_PORT=CA[thou]//DisplayThousandthPlaceNumber
n=1
DelayMs(5)
}
}
voidDelayMs(unsignedintMs)
{
intdelay_cnst
while(Ms>0)
{
Ms
for(delay_cnst=0delay_cnst<220delay_cnst++)
}
}
TocompiletheaboveCcodeyoumustneedtheMplabsoftwareandHiTechCCompiler.Theymustbe
properlysetupandaprojectwithcorrectsettingsmustbecreatedinordertocompilethecode.Tocompilethe
abovecode,theCfilemustbeaddedtotheproject.
InMplab,youwanttodevelopordebugtheprojectwithoutanyhardwaresetup.Youmustcompilethecodefor
generatingHEXfile.IndebuggingMode,youwanttochecktheportoutputwithoutPIC16F/18FPrimer
Board.
ThePICKIT2softwareisusedtodownloadthehexfileintoyourmicrocontrollerICPIC16F877AthroughUSB
port.
TestingtheI2CSevensegmentwithPIC16F
Give+12VpowersupplytoPIC16F/18FPrimerBoardthefoursevensegmentdisplayisconnectedwiththe
PIC16F/18FPrimerBoard.FirstchecktheentiresevensegmentsLEDsareproperlyworkingornot.Herewe
aredisplayjust1234infoursevensegment.TheentiresevensegmentsreceiveitthroughI2C&displayitin
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
6/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
order.
Ifanydataisnotcominginsevensegments,thenyoujustchecktheentiresevensegmentsLEDsareworking
ornot.ChangethesevensegmentdriverIC&ChecktheI2Cconnections.Checkthefoursevensegments
connections.OtherwiseyoujustcheckthecodewithdebuggingmodeinMplab.Ifyouwanttoseemoredetails
aboutdebuggingjustseethevideosinbelowlink.
Howtocreate&DebugaProjectinMplabusingPIC16FusingHiTechCompiler.
GeneralInformation
ForproperworkingusethecomponentsofexactvaluesasshowninCircuitfile.Whereverpossibleuse
newcomponents.
Soldereverythinginacleanway.Amajorproblemarisesduetoimpropersoldering,solderjumpsand
loosejoints.
Usetheexactvaluecrystalshowninschematic.
Moreinstructionsareavailableinfollowingarticles,
InterfacingUARTwithPIC16F877A.
InterfacingKeyswithPIC16F877A.
UserManualofPIC16F/18FPrimerBoard.
Create&DebugaprojectinMplabusingPIC16F877A.
JointheWorld'sLargestTechnicalCommunity
SignUp
werespectyourprivacy.
StayConnected...Followus!
Resources
Blog
Videos
Presentations
BuyingGuides
Newsletters
AcrosstheWeb
Twitter
Facebook
Linkedin
Google+
YouTube
Slideshare
Scribd
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
7/8
8/3/2016
HowtoInterface7SEGwithPIC16F877A
Stumbleupon
Pinterest
MoreInformation
WarrantyInformation
ReturnPolicy
CancellationOrder
Holidays
TermsforSoftwares
RoHS
Dealership
ShippingPolicy
Company
AboutUs
Termsofuse
Privacypolicy
Terms&Conditions
Careers
Events
SiteMap
Contactus
PantechProLabsTeam
CRMLogin
Copyright2016PantechProLabsIndiaPvtLtd
ContentonthissiteislicensedunderaCreativeCommonsAttributionNonCommercialNoDerivs3.0Unported
License
https://www.pantechsolutions.net/microcontrollerboards/7segmentinterfacingwithpic16f877aprimer
8/8