<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Loginway &#187; Microchip PIC</title>
	<atom:link href="http://loginway.net/category/projects/microchip-pic/feed/" rel="self" type="application/rss+xml" />
	<link>http://loginway.net</link>
	<description></description>
	<lastBuildDate>Thu, 09 Oct 2008 19:33:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>IrDA Standard Stack for Microchip 16-Bit Microcontrollers. (New application note).</title>
		<link>http://loginway.net/irda-standard-stack-for-microchip-16-bit-microcontrollers/</link>
		<comments>http://loginway.net/irda-standard-stack-for-microchip-16-bit-microcontrollers/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 04:11:14 +0000</pubDate>
		<dc:creator>glogin</dc:creator>
				<category><![CDATA[Microchip PIC]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://loginway.net/irda%c2%ae-standard-stack-for-microchip-16-bit-microcontrollers/</guid>
		<description><![CDATA[Microchip released new application note &#8220;IrDA® Standard Stack for Microchip 16-Bit Microcontrollers&#8221;. Many members of Microchip’s families of 16-bit microcontrollers provide native IrDA standard support via their UART modules. This greatly simplifies the hardware design, which basically means that the microcontroller requires only Infrared Transmitter/Receiver. The app note gives an overview of three IrDA protocols: [...]]]></description>
			<content:encoded><![CDATA[<p>Microchip released new application note &#8220;IrDA® Standard Stack for Microchip 16-Bit Microcontrollers&#8221;.</p>
<p>Many members of Microchip’s families of 16-bit microcontrollers provide native IrDA standard support via their UART modules. This greatly simplifies the hardware design, which basically means that the microcontroller requires only Infrared Transmitter/Receiver.</p>
<p>The app note gives an overview of three IrDA protocols:</p>
<ul>
<li>IrCOMM 9-Wire Cooked</li>
<li>OBEX</li>
<li>IrCOMM 3-Wire Raw</li>
</ul>
<p>MICROCHIP’S IrDA® STACK TOOL is the tool which will create project files required to use the Microchip IrDA Standard Stack. It will also indicate which library file to include in the project, based on the selected protocol and device type.</p>
<p>Drawing 1. (large view)<br />
<a href="http://www.loginway.net/images/mist.jpg"><img width="420" src="http://www.loginway.net/images/mist.jpg" alt="Microchip IrDA" height="480" /></a></p>
<p>The <a href="http://ww1.microchip.com/downloads/en/AppNotes/01071a.pdf">AN1071</a> app note, source code and Microchip IrDA Standard Stack libraries are available for download from the Microchip website.</p>
]]></content:encoded>
			<wfw:commentRss>http://loginway.net/irda-standard-stack-for-microchip-16-bit-microcontrollers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bootloader for dsPIC30F/33F and PIC24F/24H Devices. (New application note).</title>
		<link>http://loginway.net/bootloader-for-dspic30f-33f-and-pic24f-24h-devices/</link>
		<comments>http://loginway.net/bootloader-for-dspic30f-33f-and-pic24f-24h-devices/#comments</comments>
		<pubDate>Sat, 26 May 2007 06:09:04 +0000</pubDate>
		<dc:creator>glogin</dc:creator>
				<category><![CDATA[Microchip PIC]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://loginway.net/bootloader-for-dspic30f33f-and-pic24f24h-devices/</guid>
		<description><![CDATA[Microchip published new application note AN1094 &#8220;Bootloader for dsPIC30F/33F and PIC24F/24H Devices&#8221;. The bootloader for dsPIC30F/33F and PIC24H/24F devices is used to load and run an application on the target device. The bootloader consists of two applications: Target side bootloader application which must be programmed into dsPIC30F/33F or PIC24F/24H program memory prior to bootloader operation. Host [...]]]></description>
			<content:encoded><![CDATA[<p>Microchip published new application note AN1094 &#8220;Bootloader for dsPIC30F/33F and PIC24F/24H Devices&#8221;.</p>
<p>The bootloader for dsPIC30F/33F and PIC24H/24F devices is used to load and run an application on the target device. The bootloader consists of two applications:</p>
<ul>
<li>Target side bootloader application which must be programmed into dsPIC30F/33F or PIC24F/24H program memory prior to bootloader operation.</li>
</ul>
<ul>
<li>Host PC bootloader application which communicates with the target side bootloader.</li>
</ul>
<p>The bootloader parses the program HEX file and then copies it into the appropriate program and EEPROM memory (if present) on the target device via the communication channel (UART, CAN, etc.). The bootloader target application is located in the dedicated program memory region, starting at address 0&#215;100 (for dsPIC30F devices) or 0&#215;400 (for all other device families). On start-up, the bootloader reads program memory address 0&#215;600 (for dsPIC30F family) or address 0xC00 (for all other device families), which contains a bootloader delay value. If the bootloader fails to detect UART activity within the time period specified by the delay value, it suspends itself and transfers execution to the user application located at program memory address 0&#215;602 (for dsPIC30F family) or address 0xC02 (for all other families). On the other hand, if the bootloader detects UART activity before it suspends itself, it programs both EEPROM (if present) and program memories with the data it receives from the bootloader host application via UART interface. The bootloader host application parses the HEX file containing the user application (generated by MPLAB® IDE and sends this data to the bootloader target application via UART. The bootloader host application also supports additional features, such as read of program and EEPROM memories.</p>
<p>More datails at <a href="http://ww1.microchip.com/downloads/en/AppNotes/01094a.pdf">AN1094 Application Note</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://loginway.net/bootloader-for-dspic30f-33f-and-pic24f-24h-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to play a melody with a piezo buzzer and PIC16F877A microcontroller?</title>
		<link>http://loginway.net/how-to-play-a-melody-with-a-piezo-buzzer-and-pic16f877a-microcontroller/</link>
		<comments>http://loginway.net/how-to-play-a-melody-with-a-piezo-buzzer-and-pic16f877a-microcontroller/#comments</comments>
		<pubDate>Sat, 05 May 2007 12:39:13 +0000</pubDate>
		<dc:creator>glogin</dc:creator>
				<category><![CDATA[Microchip PIC]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://loginway.net/how-to-play-a-melody-with-a-piezo-buzzer-and-pic16f877a-microcontroller/</guid>
		<description><![CDATA[This example demonstrates how to play a simple melody using the PIC microcontroller and piezo buzzer. The circuit was assembled on the solderless breadboard and tested on the PIC-01 Development Board. For programming, the CCS C was employed.Buzzer&#8217;s input is simply connected to the D0 pin of the microcontroller. Drawing 1. (large view) Because buzzers have a [...]]]></description>
			<content:encoded><![CDATA[<p>This example demonstrates how to play a simple melody using the PIC microcontroller and piezo buzzer. The circuit was assembled on the solderless breadboard and tested on the <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a>. For programming, the CCS C was employed.Buzzer&#8217;s input is simply connected to the D0 pin of the microcontroller.<br />
Drawing 1. (large view)<br />
<a href="http://www.loginway.net/images/buzzer_pic_development_board.jpg"><img width="420" src="http://www.loginway.net/images/buzzer_pic_development_board.jpg" alt="PIC-01 Development Board buzzer" height="300" /></a></p>
<p>Because buzzers have a narrow bandwidth, the quality of sound is rather poor, and some frequencies sounds louder whereas other are attenuated.  But, some quite simple melodies can be played, like this first notes of Beethoven&#8217;s &#8220;For Elise&#8221;..    </p>
<p>Drawing 2. (large view)<br />
<a href="http://www.loginway.net/images/for_elise.jpg"><img width="420" src="http://www.loginway.net/images/for_elise.jpg" alt="For Elise" height="45" /></a></p>
<p> /*************************************************</p>
<p>buzzer.c</p>
<p>*************************************************/<br />
#include &lt;16f877a.h&gt;<br />
#fuses xt, nowdt, noprotect, nolvp, noput<br />
#use delay (clock=4000000)</p>
<p>int i,j;</p>
<p>play(pitch, note){<br />
 for(j=0;j&lt;note;j++){<br />
   for(i=0;i&lt;15;i++){<br />
    delay_us(pitch);<br />
    output_high(pin_d0);<br />
    delay_us(pitch);<br />
    output_low(pin_d0);<br />
   }<br />
 }</p>
<p>}<br />
main()             <br />
{<br />
const int pitch_C6=478;<br />
const int pitch_Db6=451;<br />
const int pitch_D6=426;<br />
const int pitch_Eb6=402;<br />
const int pitch_E6=379;<br />
const int pitch_F6=358;<br />
const int pitch_Gb6=338;<br />
const int pitch_G6=319;<br />
const int pitch_Ab6=301;<br />
const int pitch_A6=284;<br />
const int pitch_Bb6=268;<br />
const int pitch_B6=253;<br />
const int pitch_C7=238;<br />
const int pitch_Db7=226;<br />
const int pitch_D7=212;<br />
const int pitch_Eb7=200;<br />
const int pitch_E7=189;<br />
const int pitch_F7=179;<br />
const int pitch_Gb7=169;<br />
const int pitch_G7=159;<br />
const int pitch_Ab7=150;<br />
const int pitch_A7=142;<br />
const int pitch_Bb7=134;<br />
const int pitch_B7=126;<br />
const int pitch_C8=119;<br />
const int pitch_Db8=113;<br />
const int pitch_D8=106;<br />
const int pitch_Eb8=100;<br />
const int pitch_E8=95;</p>
<p>const int quarter_note=50;<br />
const int half_note=100;</p>
<p>play(pitch_E8, quarter_note);<br />
play(pitch_Eb8, quarter_note);<br />
play(pitch_E8, quarter_note);<br />
play(pitch_Eb8, quarter_note);<br />
play(pitch_E8, quarter_note);<br />
play(pitch_B7, quarter_note);<br />
play(pitch_D8, quarter_note);<br />
play(pitch_C8, quarter_note);<br />
play(pitch_A7, half_note);<br />
play(pitch_C7, quarter_note);<br />
play(pitch_E7, quarter_note);<br />
play(pitch_A7, quarter_note);<br />
play(pitch_B7, half_note);</p>
<p>play(pitch_E7, quarter_note);<br />
play(pitch_A7, quarter_note);<br />
play(pitch_Bb7, quarter_note);<br />
play(pitch_C8, half_note);</p>
<p>}</p>
<p>play(pitch, note) functions pulses the microcontroller&#8217;s output D0 in certain frequency for some certain time. Frequencies of piano scale can be found on the Internet.</p>
<p>Statement  const int pitch_C6=478;  is basicly the half of the period (1/f)/2 which corresponds to the frequency of sound (C6 here). It is not very accurate, because some time microcontroller uses for execution, but more imortant are intervals &#8211; the diffrences in pitch between notes.</p>
<blockquote><p>Source code for <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a> and hex files:<br />
<a href="http://www.loginway.com/project/buzzer.zip">buzzer.c (.zip)</a><br />
<a href="http://www.loginway.com/project/buzzer_hex.zip">buzzer.hex (.zip)</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://loginway.net/how-to-play-a-melody-with-a-piezo-buzzer-and-pic16f877a-microcontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The PCF8583 Real Time Clock &amp; PIC16F877A project on the PIC-01 Development Board.</title>
		<link>http://loginway.net/pcf8583-real-time-clock-pic16f877a-project-on-the-pic-01-development-board/</link>
		<comments>http://loginway.net/pcf8583-real-time-clock-pic16f877a-project-on-the-pic-01-development-board/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 08:39:18 +0000</pubDate>
		<dc:creator>glogin</dc:creator>
				<category><![CDATA[Microchip PIC]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://loginway.net/pcf8583-real-time-clock-pic16f877a-project-on-the-pic-01-development-board/</guid>
		<description><![CDATA[This example shows how to realize the Real Time Clock (RTC) using the PCF8583 and PIC16F877A. The ciruit was assembled using solderless breadboard of the PIC-01 Development Board by Loginway. The chip was programmed using the CCS C compiler. The project uses typical PCF8583 application. Because on the PIC-01 Development Board there is already an [...]]]></description>
			<content:encoded><![CDATA[<p>This example shows how to realize the Real Time Clock (RTC) using the PCF8583 and PIC16F877A. The ciruit was assembled using solderless breadboard of the <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a> by Loginway. The chip was programmed using the CCS C compiler.</p>
<p>The project uses typical PCF8583 application. Because on the PIC-01 Development Board there is already an I2C device (an I2C EEPROM memory with the address set to A0A1A2=000), the A0 pin has been set high.</p>
<p>The PCF8583.h library contains three functions:</p>
<ul>
<li><code>init_PCF8583(); </code></li>
<li><code>write_PCF8583(BYTE address, BYTE data);</code></li>
<li><code>read_PCF8583(BYTE address);</code></li>
</ul>
<p><code><br />
//--------------------------------------------------------<br />
// Library for a pcf8583p - RTC/Calendar with 240x8bit RAM<br />
// and I2C interface<br />
// Pin Layout:<br />
// |<br />
// | 1: OSCI Oscillator input | 8: VCC +5V |<br />
// |<br />
// | 2: OSCO OScillator output| 7: !INT Interruption output |<br />
// |<br />
// | 3: A0 I2C Address | 6: SCL EEPROM_SCL and Pull-Up |<br />
// |<br />
// | 4: VSS GND | 5: SDA EEPROM_SDA and Pull-Up |<br />
// ------------------------------------------------<br />
//<br />
// PCF8583p Slave I2C Address<br />
//<br />
// 1 0 1 0 0 0 A0 R/!W<br />
//<br />
</code><code><code>//--------Pin definition--------//<br />
#define PCF8583_SDA PIN_C4<br />
#define PCF8583_SCL PIN_C3</code><code> </code></code><code></code><code><code></code><code>#define PCF8583_WRITE_ADDRESS 0xA2 //Pin A0 High<br />
#define PCF8583_READ_ADDRESS 0xA3</code><code> </code></code><code></code><code></code><code>#ifndef PCF8583_WRITE_ADDRESS<br />
#define PCF8583_WRITE_ADDRESS 0xA0 //Pin A0 Low<br />
#define PCF8583_READ_ADDRESS 0xA1<br />
#endif</code><code> </code><code>#use i2c(master, sda=PCF8583_SDA, scl=PCF8583_SCL)</code><code>void init_PCF8583() {<br />
  output_float(PCF8583_SCL);<br />
  output_float(PCF8583_SDA);<br />
}</code><code>BOOLEAN PCF8583_ready() {<br />
  int1 ack;<br />
  i2c_start();<br />
  ack = i2c_write(PCF8583_WRITE_ADDRESS);<br />
  i2c_stop();<br />
  return !ack;<br />
}</code><code>void write_PCF8583(BYTE address, BYTE data) {<br />
  while(!PCF8583_ready());<br />
  i2c_start();<br />
  i2c_write(PCF8583_WRITE_ADDRESS);<br />
  i2c_write(address);<br />
  i2c_write(data);<br />
  i2c_stop();<br />
}</code><code>BYTE read_PCF8583(BYTE address) {<br />
  BYTE data;</code><code>while(!PCF8583_ready());<br />
  i2c_start();<br />
  i2c_write(PCF8583_WRITE_ADDRESS);<br />
  i2c_write(address);<br />
  i2c_start();<br />
  i2c_write(PCF8583_READ_ADDRESS);<br />
  data=i2c_read(0);<br />
  i2c_stop();<br />
  return(data);<br />
}</p>
<p>The rtc.c listing shows has to read date and time from the PCF8583.<code></code><code><br />
//-------------------------------<br />
//  rtc.c<br />
//  pcf8583p RTC</code><code> </code><code><code>#include&lt;16f877a.h&gt; //Device<br />
#use delay (clock=4000000) //4.00 MHz</code></code><code><code></code><code>#include"lcd_new.h" //LCD driver<br />
#fuses xt,nowdt,protect,noput,nolvp //Fuses</code><code> </code></code><code><code></code><code>#include&lt;pcf8583.h&gt;</code><code></code></code><code><code></p>
<pcf8583.h></pcf8583.h></code></code></p>
<p></code><code>byte sec,min,hour,year,month,day,weekday;char const weekday_names[7][4] =<br />
{<br />
{"Sun"},<br />
{"Mon"},<br />
{"Tue"},<br />
{"Wed"},<br />
{"Thu"},<br />
{"Fri"},<br />
{"Sat"}<br />
};</code><code>void main(void)<br />
{<br />
lcd_init(); //lcd start<br />
lcd_init_custom_chars();</code><code>init_PCF8583();while(TRUE)<br />
{<br />
delay_ms(100);<br />
lcd_gotoxy(1,1);</p>
<p>weekday=read_PCF8583(0x06);<br />
weekday&gt;&gt;=5;<br />
printf(lcd_putc,"%s",weekday_names[weekday]);</p>
<p>day=read_PCF8583(0x05);<br />
printf(lcd_putc," %x/",day&#038;0x3f);</p>
<p>month=read_PCF8583(0x06);<br />
printf(lcd_putc,"%x/",month&#038;0x1f);</p>
<p>year=read_PCF8583(0x05);<br />
printf(lcd_putc,"20%x",year&#038;0xc0);</p>
<p>hour=read_PCF8583(0x04);<br />
printf(lcd_putc,"\n%x:",hour);</p>
<p>min=read_PCF8583(0x03);<br />
printf(lcd_putc,"%x:",min);</p>
<p>sec=read_PCF8583(0x02);<br />
printf(lcd_putc,"%x",sec);<br />
}</p>
<p>}</code></p>
<p>For further development, it would be sensible to include set_time() and set_date() functions and using interrupts.</p>
<p>All files available here:<br />
<a href="http://www.loginway.com/project/rtc.zip">rtc.c (.zip)</a><br />
<a href="http://www.loginway.com/project/rtc_hex.zip">rtc.hex (.zip)</a><br />
<a href="http://www.loginway.com/project/PCF8583.zip">PCF8583.h (.zip)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://loginway.net/pcf8583-real-time-clock-pic16f877a-project-on-the-pic-01-development-board/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The RC5 decoder based on a PIC16F877A and PIC-01 Developement Board.</title>
		<link>http://loginway.net/the-rc5-decoder-based-on-a-pic16f877a-and-pic-01-developement-board/</link>
		<comments>http://loginway.net/the-rc5-decoder-based-on-a-pic16f877a-and-pic-01-developement-board/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 09:54:23 +0000</pubDate>
		<dc:creator>glogin</dc:creator>
				<category><![CDATA[Microchip PIC]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://loginway.net/the-rc5-decoder/</guid>
		<description><![CDATA[1. Introduction. It is an example of an RC5 receiver and decoder. It shows popular Philips RC5 coding. It was tested using simple hardware assembled on the PIC-01 Development Board connected to a PC through an RS232. All of the routines were written in C using the CCS compiler. 2. A little bit of theory. [...]]]></description>
			<content:encoded><![CDATA[<p>1. Introduction.<br />
It is an example of an RC5 receiver and decoder. It shows popular Philips RC5 coding. It was tested using simple hardware assembled on the <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a> connected to a PC through an RS232. All of the routines were written in C using the CCS compiler.</p>
<p>2. A little bit of theory.</p>
<p>The RC5 is Philips&#8217; standard for infra red communication. It is widely used for remote controls in consumer electronics.</p>
<p>The RC5 uses Manchester coding. It is a form of data communications line code in which each bit of data is signified by at least one transition. Manchester coding is considered to be self-clocking, which means that accurate synchronization of data stream is possible. Each bit is transmitted over a predefined time period. Manchester codes have a transition at the middle of each period.</p>
<p>The RC5 code uses a modulation of a 36kHz IR carrier frequency. The code is 14-bit long. A 5-bit address and a 6-bit command are preceded by 3 control bits.</p>
<p>Drawing 1. (large view)<br />
<a href="http://www.loginway.net/images/rc5.gif"><img width="420" src="http://www.loginway.net/images/rc5.gif" alt="rc5 circuit" height="130" /></a></p>
<p>The first two start bits are both logical &#8217;1&#8242;. The third bit is a toggle bit. This bit is inverted every time a key is released and pressed again. The next 5 bits represent the IR device address, and the following 6 bits represent the command. Addresses and commands are sent in the MSB first order.</p>
<p>3. Hardware.</p>
<p>The TSOP1736 is a miniature receiver for infra red control systems. It works in its typical application circuit. The U1 output pin is connected to the RB0 pin of the PIC microcontroller. The output pin of the U1 is normally high. Receiving an infra red signal pulls the output low and the microcontroller can decode the information in an interrupt call.</p>
<p>Because the PIC uses an interruption on RB0 input, the LED jumper on the <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a> should be removed.</p>
<p>Drawing 2. (large view)<br />
<a href="http://www.loginway.net/images/rc5sch.gif"><img width="430" src="http://www.loginway.net/images/rc5sch.gif" alt="rc5 circuit" height="250" /></a></p>
<p>4. Listing.</p>
<p>The output of the TSOP1736 is normally high and the RC5 code on its output is inverted. A low signal on the PIC input calls an interrupt routine. The microcontroller waits for a high level and times how long the low state has remained. If the time has been 800-1000us, the PIC starts decoding. It reads the input approximately every 1.78ms and writes data into a buffer. After that the address and command are displayed on an LCD and sent through the RS232.</p>
<p>The code was written in C and tested on the PIC development board by LoginWay.</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
//rc5.c<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>#include&lt;16f877a.h&gt;<br />
#use delay (clock=4000000)<br />
#fuses xt,nowdt,noprotect,noput,nolvp<br />
#use rs232 (Baud=9600,xmit=pin_c6,rcv=pin_c7) //RS232 transmission setup<br />
#include&#8221;lcd_new.h&#8221;</p>
<p>int counter,i,com,adr;<br />
int16 buffer;</p>
<p>#int_ext //interrupt<br />
int_IR()<br />
{<br />
counter=0; //reset counter and buffer<br />
buffer=0;<br />
disable_interrupts(int_ext); //disable interrupts</p>
<p>while(!input(pin_b0)) //wait for high level<br />
{ delay_us(15);<br />
++counter; } //time how long has been low<br />
if(counter&gt;=38&amp;&amp;counter&lt;=45) //if from about 800 to 1000 us<br />
{ //do routines<br />
delay_us(200);<br />
for(i=0;i&lt;13;i++) //13 following bits<br />
{<br />
if(input(pin_b0)) //if the input high<br />
{bit_set(buffer,0); //set the LSB and shift left<br />
buffer&lt;&lt;=1;}<br />
else //otherwise just shift<br />
buffer&lt;&lt;=1;<br />
delay_us(1740); //wait for naxt bit<br />
}<br />
buffer&gt;&gt;=1; //shift 1 right because of last reading<br />
com=buffer&amp;0b00111111; //command is 6-bit long; ignore the rest<br />
buffer&gt;&gt;=6; //shift 6 right<br />
adr=buffer&amp;0b00011111; //address is 5-bit long; ignore the rest</p>
<p>//display on an LCD<br />
printf(lcd_putc,&#8221;\fAddress:%u\nCommand:%u&#8221;,adr,com);<br />
printf(&#8220;A%uC%u&#8221;,adr,com); //send bytes to the rs232<br />
delay_ms(150);} //wait<br />
return(0); //return to main<br />
}</p>
<p>main()<br />
{</p>
<p>lcd_init();<br />
while(1)<br />
{<br />
enable_interrupts(int_ext); //enable external interrupt<br />
ext_int_edge(H_to_L); //falling edge<br />
enable_interrupts(global); //enable interrupts<br />
}<br />
}</p>
<p>5. Usage.</p>
<p>You can connect your <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a> to the PC through an RS232 serial straight-through cable. To check your program use the Hyper Terminal. Set the appropriate COM port and set the transmission on 9600bd, no parity, 1-bit stop, no flow control.</p>
<p>You can use your RC5 remote controller to control some of your computer applications like WinAmp and Windows Media Player.</p>
<p>To find out more follow the links below.</p>
<p>The <a href="http://www.vishay.com/docs/82030/82030.pdf">TSOP1736</a> data sheet.<br />
<a href="http://www.loginway.com/project/rc5.rar">RC5.hex (.rar)</a> file is available here.<br />
Here you can find <a href="http://www.microcontroller.republika.pl/IR.htm">WinAmp plug-in</a> and some instructions how to install it.<br />
Some useful information about the <a href="http://www.lirc.org/">IR remote control</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://loginway.net/the-rc5-decoder-based-on-a-pic16f877a-and-pic-01-developement-board/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The PIC16F877A&#8217;s integrated Analog to Digital Converter (ADC).</title>
		<link>http://loginway.net/the-pic16f877-as-integrated-analog-to-digital-converter-adc/</link>
		<comments>http://loginway.net/the-pic16f877-as-integrated-analog-to-digital-converter-adc/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 09:43:45 +0000</pubDate>
		<dc:creator>glogin</dc:creator>
				<category><![CDATA[Microchip PIC]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://loginway.net/the-pic16f877as-integrated-analog-to-digital-converter/</guid>
		<description><![CDATA[1. Introduction. This is an example how to use integrated Analog to Digital Converter (ADC) of the PIC16F877A. The code was written in the CCS C and tested on the PIC-01 Development Board. 2. The ADC. The PIC16F877A microcontroller has a 10-bit 8-channel integrated Analog to Digital Converter. In the analog to digital conversion the [...]]]></description>
			<content:encoded><![CDATA[<p>1. Introduction.</p>
<p>This is an example how to use integrated Analog to Digital Converter (ADC) of the PIC16F877A. The code was written in the CCS C and tested on the <a href="http://www.loginway.com/online_shop.htm">PIC-01 Development Board</a>.</p>
<p>2. The ADC.</p>
<p>The PIC16F877A microcontroller has a 10-bit 8-channel integrated Analog to Digital Converter. In the analog to digital conversion the ADC can use either on-board RC oscillator or divided clock signal (Fosc). The freqency can be chosen in programming from Fosc/2, Fosc/4, Fosc/8, Fosc/16, Fosc/32, Fosc/64. The voltage input range depends on the reference voltege on inputs Vref+ (RA3) and Vref- (RA2). If the inputs are not connected the reference volage ranges from Vss to Vcc.</p>
<p>3. Circuit.</p>
<p>There is a 4.7k pot installed on the PIC-01 Development Board for the purpose of the ADC. The pot is connected to the RA0 input and between the GND and Vcc of the power supply.</p>
<p>4. Listing.</p>
<p>The program was written in the CCS C and uses the PIC16F877A standard library. The RA0 pin has to be set as the analog input. The ADC uses the internal RC oscillator.</p>
<p>The ADC has the 10-bit resolution, which means that the 0-5V range is divided between 210 = 1024 levels. It means that 1-bit represents 5V / 1024 = 0.0048V = 4.8mV voltage.</p>
<p>The voltage read from the RA0 input is displayed on the PIC-01 Development Board&#8217;s LCD in the format &#8220;Voltage = X.XX V&#8221;.</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
//<br />
// acd.c<br />
//<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>#include&lt;16f877a.h&gt; //Device<br />
#fuses xt,nowdt,protect,noput,nolvp //Fuses<br />
#device adc=10 //10-bit ADC<br />
#use delay (clock=4000000) //4.00 MHz<br />
#use rs232 (Baud=9600) //RS-232 parametres<br />
//(only for printf function)<br />
#include&#8221;llcd_new.h&#8221; //LCD driver</p>
<p>main()<br />
{</p>
<p>float c;<br />
lcd_init();<br />
set_tris_a(0b000001); //RA0 anlog<br />
setup_adc(adc_clock_internal); //internal clock<br />
setup_adc_ports(ra0_analog); //RA0 analog input<br />
set_adc_channel(0); //set channel</p>
<p>while(1)<br />
{<br />
c=read_adc(); //voltage conversion<br />
delay_ms(150); //10-bit = 1024<br />
lcd_gotoxy(1,1); //0-5 V and 1024 levels<br />
printf(lcd_putc,&#8221;Voltage = %1.2f V &#8220;,(c*5)/1024); //calculate voltage<br />
delay_ms(150);<br />
}<br />
}</p>
<p>Files are available here:<br />
<a href="http://www.loginway.com/project/adc.zip">adc.c (.zip)</a><br />
<a href="http://www.loginway.com/project/adc_hex.zip">adc.hex (.zip)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://loginway.net/the-pic16f877-as-integrated-analog-to-digital-converter-adc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
