Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
ඔයාගෙ Assignment හෝ Thesis එක හරියට හදාගමු
ErMurazor
Updated:
Yesterday at 10:52 PM
Ad icon
BlackWall V2ray servers
hu KANNA
Updated:
Wednesday at 4:58 AM
Peppa Pig Family Plush Toy Set – 5 Characters
anil1961
Updated:
Sep 19, 2026
Ad icon
Express VPN PC - 1 Year Rs. 600.00
Sanathbh
Updated:
Sep 19, 2026
Ad icon
Capcut Pro 7 Days Team Plan - Rs. 3️⃣0️⃣0️⃣
Sanathbh
Updated:
Sep 19, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Microcontroller Programming with MikroC PRO for PIC
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Little DJ" data-source="post: 10910562" data-attributes="member: 320663"><p><strong>LED Blink Circuit with 16F877A Microcontroller</strong></p><p></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">After creating the project in MikroC PRO for PIC software, as the next step we could write our first programme to blink LED's using 16F877A Microcontroller. </span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">We could write our programme using ANSI C language. MikroC PRO provides full featured ANSI C compiler for PIC devices from Microchip®. </span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><strong>TRISB</strong> - TRISB is a 8 bit register which use to assign the PORT B of the microcontroller as input or output. </span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> <strong> If TRISB=0 PORT B is assigned as output.</strong></span></p><p><span style="font-size: 15px"><strong> If TRISB=1 PORT B is assigned as output.</strong></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">This can be also done as follows </span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"> <strong> TRISB= b'00000000; //In Binary</strong></span></p><p><span style="font-size: 15px"><strong> TRISB= 0x00; // In Hexadecimal </strong></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">Same procedure can be done for other ports (PORT A, PORT C, PORT D, PORT E)as well.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><strong>PORTB</strong> - Assigning values for PORT B register (8 bit) we could get inputs or give outputs from the Microcontroller </span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px">If we need to power up pin 0 and pin 2 of the PORT B it could do as follow.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"> <strong> PORTB= b'00000101;</strong></span></p><p><span style="font-size: 15px"><strong> or</strong></span></p><p><span style="font-size: 15px"><strong> PORTB.F0=1;</strong></span></p><p><span style="font-size: 15px"><strong> PORTB.F2=1;</strong></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><strong>Delay_ms(1000)</strong>- This is the delay function which provides by MikroC to make delays according to the user requirement. Changing the value inside the brackets we could make the delay in milliseconds.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">Code:</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">[code]</span></p><p><span style="font-size: 15px">/************************************************\</span></p><p><span style="font-size: 15px">* www.electronicworkspace.com *</span></p><p><span style="font-size: 15px">* Electronics for Everyone *</span></p><p><span style="font-size: 15px">* Date: 01/09/2011 *</span></p><p><span style="font-size: 15px">* LED Blink with 16F877A *</span></p><p><span style="font-size: 15px">\************************************************/</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">void main() {</span></p><p><span style="font-size: 15px">TRISB=0;</span></p><p><span style="font-size: 15px">PORTB=0;</span></p><p><span style="font-size: 15px">TRISD=0;</span></p><p><span style="font-size: 15px">PORTD=0;</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"> while(1){</span></p><p><span style="font-size: 15px"> PORTB.RB0=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB0=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB1=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB1=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB2=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB2=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB3=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB3=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB4=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB4=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB5=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB5=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB6=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB6=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTB.RB7=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTB.RB7=0;</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"> PORTD.RD0=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTD.RD0=0;</span></p><p><span style="font-size: 15px"> </span></p><p><span style="font-size: 15px"> PORTD.RD1=1;</span></p><p><span style="font-size: 15px"> Delay_ms(750);</span></p><p><span style="font-size: 15px"> PORTD.RD1=0;</span></p><p><span style="font-size: 15px"> }</span></p><p><span style="font-size: 15px">}</span></p><p><span style="font-size: 15px">[/code]</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><strong>How to compile the code:</strong></span></p><p><span style="font-size: 15px"><strong>Go to Build ----> Click Build (Ctrl + F9)</strong></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><img src="http://4.bp.blogspot.com/-GAEgGZ_LRDw/Tl-BxUrX60I/AAAAAAAAAIY/W_gcomVZgLs/s1600/16F877A+LED+Blink.JPG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">This programme can be simulate using PROTEUS software (ISIS Professional)</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><img src="http://1.bp.blogspot.com/-rKcxYrxA3Ww/Tl-DTji1kiI/AAAAAAAAAIc/5nqBdo-flXQ/s1600/16F877A+LED+Blink+01.JPG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">Created HEX file from the MikroC can be imported to the ISIS Professional software and test.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">[YOUTUBE]I-pTvdMkzW0[/YOUTUBE]</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><strong>Download MikroC code & PROTEUS Design: </strong><a href="http://www.fileserve.com/file/xP44Pmq/16F877A_LED_Blink.rar" target="_blank"><strong>Click Here</strong></a></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"><span style="font-size: 18px">More info: <a href="http://www.electronicworkspace.com/2011/09/led-blink-circuit-with-16f877a.html" target="_blank">Click Here</a></span></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px"></span></p></blockquote><p></p>
[QUOTE="Little DJ, post: 10910562, member: 320663"] [b]LED Blink Circuit with 16F877A Microcontroller[/b] [SIZE="4"] After creating the project in MikroC PRO for PIC software, as the next step we could write our first programme to blink LED's using 16F877A Microcontroller. We could write our programme using ANSI C language. MikroC PRO provides full featured ANSI C compiler for PIC devices from Microchip®. [B]TRISB[/B] - TRISB is a 8 bit register which use to assign the PORT B of the microcontroller as input or output. [B] If TRISB=0 PORT B is assigned as output. If TRISB=1 PORT B is assigned as output.[/B] This can be also done as follows [B] TRISB= b'00000000; //In Binary TRISB= 0x00; // In Hexadecimal [/B] Same procedure can be done for other ports (PORT A, PORT C, PORT D, PORT E)as well. [B]PORTB[/B] - Assigning values for PORT B register (8 bit) we could get inputs or give outputs from the Microcontroller If we need to power up pin 0 and pin 2 of the PORT B it could do as follow. [B] PORTB= b'00000101; or PORTB.F0=1; PORTB.F2=1;[/B] [B]Delay_ms(1000)[/B]- This is the delay function which provides by MikroC to make delays according to the user requirement. Changing the value inside the brackets we could make the delay in milliseconds. Code: [code] /************************************************\ * www.electronicworkspace.com * * Electronics for Everyone * * Date: 01/09/2011 * * LED Blink with 16F877A * \************************************************/ void main() { TRISB=0; PORTB=0; TRISD=0; PORTD=0; while(1){ PORTB.RB0=1; Delay_ms(750); PORTB.RB0=0; PORTB.RB1=1; Delay_ms(750); PORTB.RB1=0; PORTB.RB2=1; Delay_ms(750); PORTB.RB2=0; PORTB.RB3=1; Delay_ms(750); PORTB.RB3=0; PORTB.RB4=1; Delay_ms(750); PORTB.RB4=0; PORTB.RB5=1; Delay_ms(750); PORTB.RB5=0; PORTB.RB6=1; Delay_ms(750); PORTB.RB6=0; PORTB.RB7=1; Delay_ms(750); PORTB.RB7=0; PORTD.RD0=1; Delay_ms(750); PORTD.RD0=0; PORTD.RD1=1; Delay_ms(750); PORTD.RD1=0; } } [/code] [B]How to compile the code:[/B] [B]Go to Build ----> Click Build (Ctrl + F9)[/B] [IMG]http://4.bp.blogspot.com/-GAEgGZ_LRDw/Tl-BxUrX60I/AAAAAAAAAIY/W_gcomVZgLs/s1600/16F877A+LED+Blink.JPG[/IMG] This programme can be simulate using PROTEUS software (ISIS Professional) [IMG]http://1.bp.blogspot.com/-rKcxYrxA3Ww/Tl-DTji1kiI/AAAAAAAAAIc/5nqBdo-flXQ/s1600/16F877A+LED+Blink+01.JPG[/IMG] Created HEX file from the MikroC can be imported to the ISIS Professional software and test. [YOUTUBE]I-pTvdMkzW0[/YOUTUBE] [B]Download MikroC code & PROTEUS Design: [/B][URL="http://www.fileserve.com/file/xP44Pmq/16F877A_LED_Blink.rar"][B]Click Here[/B][/URL] [SIZE="5"]More info: [URL="http://www.electronicworkspace.com/2011/09/led-blink-circuit-with-16f877a.html"]Click Here[/URL][/SIZE] [/SIZE] [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom