<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://elinux.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://elinux.org/api.php?action=feedcontributions&amp;user=Millerap&amp;feedformat=atom</id>
		<title>eLinux.org - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://elinux.org/api.php?action=feedcontributions&amp;user=Millerap&amp;feedformat=atom"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/Special:Contributions/Millerap"/>
		<updated>2013-05-20T04:58:31Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.21alpha</generator>

	<entry>
		<id>http://elinux.org/User:Popenhjc</id>
		<title>User:Popenhjc</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Popenhjc"/>
				<updated>2012-11-08T16:48:02Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Attends Rose-Hulman.&lt;br /&gt;
Class of 2013.&lt;br /&gt;
In Embedded Linux.&lt;br /&gt;
[[Category:ECE497 |Up]]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/User:Millerap</id>
		<title>User:Millerap</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/User:Millerap"/>
				<updated>2012-11-08T16:47:09Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: Replaced content with &amp;quot;Um&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Um]]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-02T15:56:55Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Building and Running the Sin_Approximation Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: Some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summing circuit which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
This activates the PRU module in the kernel so that its memory and all of its components are accessible.&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. &lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 and turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t/fs) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t/fs)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t/fs)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated due to precise measuring for the sampling frequency, but because this is being run on PRU0, DRAM starts at 0x0. If you feel that you need to change the sampling frequency at any point here's a bit on how to calculate the amount of instructions you need to delay in total.&lt;br /&gt;
&lt;br /&gt;
 sample_period = 1/sample_frequency&lt;br /&gt;
 .&lt;br /&gt;
 sample_period/(number_instructions_delay_loop*5ns) = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 Then count the amount of instructions before or after the loop and nock off that many instructions to delay. This will of course&lt;br /&gt;
 need to be accounted for in the duty cycle, and some sampling frequencies may not offer all duty_percentages.&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = number_on_instruction_delay/number_off_instruction_delay&lt;br /&gt;
 .&lt;br /&gt;
 number_on_instruction_delay + number_off_instruction_delay = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 -&amp;gt;(duty_percent + 1)*total_number_instruction_to_delay_per_period = number_on_instruction_delay&lt;br /&gt;
&lt;br /&gt;
Of course a few other numbers will have to be adjusted, such as the number of samples to read from memory. Because it has to read in 4 bytes of data, this will end up being:&lt;br /&gt;
 total_number_instructions_to_delay_per_period*4+4&lt;br /&gt;
This way the number will reset to 0 as soon as it goes over the limit of memory to be read.&lt;br /&gt;
&lt;br /&gt;
To build this example, follow the same procedure as before, and wire GPIO7 (Pin 42) through a speaker to ground. The output produced will be an 880Hz sin wave approximation.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
During the project we were able to get an approximated 880Hz sine wave to play by changing a pulse width modulation duty cycle to approximate a dc voltage output, as you would with an LED dimmer. You can view this in action along with a helpful tip in the youtube video: &lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=6ytju0bkkiQ&amp;amp;feature=youtu.be PWM Demo].&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
In the first examples, you can see that the GPIO can be toggled on and off simply by editing locations in memory from the PRU. You simply set how long you want the LED to be on and how long you want the LED to be off, and delay the time between on and off to create the desired latency.&lt;br /&gt;
&lt;br /&gt;
In the following example, the premise changes slightly. The operation of our code is simple, the PRU offers precise instruction delay of 5ns per instruction. With this we were able to create a delay of instructions that would be a sampling frequency, and in between this delay of instructions we were able to have a set amount of instructions for which the GPIO was on, and a set amount where the GPIO was off. Also, memory could be set from a C program, and then read by the PRU. This came in handy when approximating the sine wave because C offers the math.h header file that has the sin function included and can give approximate numbers to send to the PRU. The amount of delay on and off could be set dynamically every time the loop began by reading the next bit of data stored in memory, thus creating an average voltage that approximated a playable sine wave.&lt;br /&gt;
&lt;br /&gt;
Refer to How the C Code Works, How the Assembly Code Works, and Building and Running Sin_Approximation for more details.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
For future work there are a few interesting features that we were not able to get to due to time limit and the amount of research needed to begin with. First, we found difficulty in accessing things such as the PWM and analog in ports. These could be further explored given the documents that we have dug up, and some exploration on Google. Second, we wanted to read audio from the analog input and adjust the duty_cycle of the PWM accordingly to have approximate audio output which is the next step to what we have done here. Third, we wanted to explore interrupts on the PRU, but were unable to find enough documentation to get an example working. So, PWM, analog in, audio capabilities, and interrupts are the possible things to look into. Also, any other time critical operations can be explored further with the BeagleBone PRU because it has a delay of exactly 5ns for every instruction.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
So, if you need precise timing, or more rapid access to a certain GPIO pin, this is a rout you might want to look into. There are a few suggestions listed above that might be interesting to see come out of using the PRU. However, if you do not require precisely timed events or faster access to GPIO pins, you might want to consider just using C on the main processor. Much of the information needed to access certain parts of the PRU and the hardware from the PRU is either very vague, or very difficult to dig up, and because the PRU is not widely used, it is difficult to find people that can offer information on the topic.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-02T15:53:45Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How the C Code Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: Some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summing circuit which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
This activates the PRU module in the kernel so that its memory and all of its components are accessible.&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. &lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 and turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t/fs) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t/fs)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t/fs)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated due to precise measuring for the sampling frequency, but because this is being run on PRU0, DRAM starts at 0x0. If you feel that you need to change the sampling frequency at any point here's a bit on how to calculate the amount of instructions you need to delay in total.&lt;br /&gt;
&lt;br /&gt;
 sample_period = 1/sample_frequency&lt;br /&gt;
 .&lt;br /&gt;
 sample_period/(number_instructions_delay_loop*5ns) = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 Then count the amount of instructions before or after the loop and nock off that many instructions to delay. This will of course&lt;br /&gt;
 need to be accounted for in the duty cycle, and some sampling frequencies may not offer all duty_percentages.&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = number_on_instruction_delay/number_off_instruction_delay&lt;br /&gt;
 .&lt;br /&gt;
 number_on_instruction_delay + number_off_instruction_delay = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 -&amp;gt;(duty_percent + 1)*total_number_instruction_to_delay_per_period = number_on_instruction_delay&lt;br /&gt;
&lt;br /&gt;
Of course a few other numbers will have to be adjusted, such as the number of samples to read from memory. Because it has to read in 4 bytes of data, this will end up being:&lt;br /&gt;
 total_number_instructions_to_delay_per_period*4+4&lt;br /&gt;
This way the number will reset to 0 as soon as it goes over the limit of memory to be read.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
During the project we were able to get an approximated 880Hz sine wave to play by changing a pulse width modulation duty cycle to approximate a dc voltage output, as you would with an LED dimmer. You can view this in action along with a helpful tip in the youtube video: &lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=6ytju0bkkiQ&amp;amp;feature=youtu.be PWM Demo].&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
In the first examples, you can see that the GPIO can be toggled on and off simply by editing locations in memory from the PRU. You simply set how long you want the LED to be on and how long you want the LED to be off, and delay the time between on and off to create the desired latency.&lt;br /&gt;
&lt;br /&gt;
In the following example, the premise changes slightly. The operation of our code is simple, the PRU offers precise instruction delay of 5ns per instruction. With this we were able to create a delay of instructions that would be a sampling frequency, and in between this delay of instructions we were able to have a set amount of instructions for which the GPIO was on, and a set amount where the GPIO was off. Also, memory could be set from a C program, and then read by the PRU. This came in handy when approximating the sine wave because C offers the math.h header file that has the sin function included and can give approximate numbers to send to the PRU. The amount of delay on and off could be set dynamically every time the loop began by reading the next bit of data stored in memory, thus creating an average voltage that approximated a playable sine wave.&lt;br /&gt;
&lt;br /&gt;
Refer to How the C Code Works, How the Assembly Code Works, and Building and Running Sin_Approximation for more details.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
For future work there are a few interesting features that we were not able to get to due to time limit and the amount of research needed to begin with. First, we found difficulty in accessing things such as the PWM and analog in ports. These could be further explored given the documents that we have dug up, and some exploration on Google. Second, we wanted to read audio from the analog input and adjust the duty_cycle of the PWM accordingly to have approximate audio output which is the next step to what we have done here. Third, we wanted to explore interrupts on the PRU, but were unable to find enough documentation to get an example working. So, PWM, analog in, audio capabilities, and interrupts are the possible things to look into. Also, any other time critical operations can be explored further with the BeagleBone PRU because it has a delay of exactly 5ns for every instruction.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
So, if you need precise timing, or more rapid access to a certain GPIO pin, this is a rout you might want to look into. There are a few suggestions listed above that might be interesting to see come out of using the PRU. However, if you do not require precisely timed events or faster access to GPIO pins, you might want to consider just using C on the main processor. Much of the information needed to access certain parts of the PRU and the hardware from the PRU is either very vague, or very difficult to dig up, and because the PRU is not widely used, it is difficult to find people that can offer information on the topic.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-02T15:51:17Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* User Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: Some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summing circuit which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
This activates the PRU module in the kernel so that its memory and all of its components are accessible.&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 and turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t/fs) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t/fs)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t/fs)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated due to precise measuring for the sampling frequency, but because this is being run on PRU0, DRAM starts at 0x0. If you feel that you need to change the sampling frequency at any point here's a bit on how to calculate the amount of instructions you need to delay in total.&lt;br /&gt;
&lt;br /&gt;
 sample_period = 1/sample_frequency&lt;br /&gt;
 .&lt;br /&gt;
 sample_period/(number_instructions_delay_loop*5ns) = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 Then count the amount of instructions before or after the loop and nock off that many instructions to delay. This will of course&lt;br /&gt;
 need to be accounted for in the duty cycle, and some sampling frequencies may not offer all duty_percentages.&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = number_on_instruction_delay/number_off_instruction_delay&lt;br /&gt;
 .&lt;br /&gt;
 number_on_instruction_delay + number_off_instruction_delay = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 -&amp;gt;(duty_percent + 1)*total_number_instruction_to_delay_per_period = number_on_instruction_delay&lt;br /&gt;
&lt;br /&gt;
Of course a few other numbers will have to be adjusted, such as the number of samples to read from memory. Because it has to read in 4 bytes of data, this will end up being:&lt;br /&gt;
 total_number_instructions_to_delay_per_period*4+4&lt;br /&gt;
This way the number will reset to 0 as soon as it goes over the limit of memory to be read.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
During the project we were able to get an approximated 880Hz sine wave to play by changing a pulse width modulation duty cycle to approximate a dc voltage output, as you would with an LED dimmer. You can view this in action along with a helpful tip in the youtube video: &lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=6ytju0bkkiQ&amp;amp;feature=youtu.be PWM Demo].&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
In the first examples, you can see that the GPIO can be toggled on and off simply by editing locations in memory from the PRU. You simply set how long you want the LED to be on and how long you want the LED to be off, and delay the time between on and off to create the desired latency.&lt;br /&gt;
&lt;br /&gt;
In the following example, the premise changes slightly. The operation of our code is simple, the PRU offers precise instruction delay of 5ns per instruction. With this we were able to create a delay of instructions that would be a sampling frequency, and in between this delay of instructions we were able to have a set amount of instructions for which the GPIO was on, and a set amount where the GPIO was off. Also, memory could be set from a C program, and then read by the PRU. This came in handy when approximating the sine wave because C offers the math.h header file that has the sin function included and can give approximate numbers to send to the PRU. The amount of delay on and off could be set dynamically every time the loop began by reading the next bit of data stored in memory, thus creating an average voltage that approximated a playable sine wave.&lt;br /&gt;
&lt;br /&gt;
Refer to How the C Code Works, How the Assembly Code Works, and Building and Running Sin_Approximation for more details.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
For future work there are a few interesting features that we were not able to get to due to time limit and the amount of research needed to begin with. First, we found difficulty in accessing things such as the PWM and analog in ports. These could be further explored given the documents that we have dug up, and some exploration on Google. Second, we wanted to read audio from the analog input and adjust the duty_cycle of the PWM accordingly to have approximate audio output which is the next step to what we have done here. Third, we wanted to explore interrupts on the PRU, but were unable to find enough documentation to get an example working. So, PWM, analog in, audio capabilities, and interrupts are the possible things to look into. Also, any other time critical operations can be explored further with the BeagleBone PRU because it has a delay of exactly 5ns for every instruction.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
So, if you need precise timing, or more rapid access to a certain GPIO pin, this is a rout you might want to look into. There are a few suggestions listed above that might be interesting to see come out of using the PRU. However, if you do not require precisely timed events or faster access to GPIO pins, you might want to consider just using C on the main processor. Much of the information needed to access certain parts of the PRU and the hardware from the PRU is either very vague, or very difficult to dig up, and because the PRU is not widely used, it is difficult to find people that can offer information on the topic.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-02T15:50:49Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Installation Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: Some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summing circuit which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
This activates the PRU so that its memory and all of its components are accessible.&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 and turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t/fs) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t/fs)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t/fs)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated due to precise measuring for the sampling frequency, but because this is being run on PRU0, DRAM starts at 0x0. If you feel that you need to change the sampling frequency at any point here's a bit on how to calculate the amount of instructions you need to delay in total.&lt;br /&gt;
&lt;br /&gt;
 sample_period = 1/sample_frequency&lt;br /&gt;
 .&lt;br /&gt;
 sample_period/(number_instructions_delay_loop*5ns) = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 Then count the amount of instructions before or after the loop and nock off that many instructions to delay. This will of course&lt;br /&gt;
 need to be accounted for in the duty cycle, and some sampling frequencies may not offer all duty_percentages.&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = number_on_instruction_delay/number_off_instruction_delay&lt;br /&gt;
 .&lt;br /&gt;
 number_on_instruction_delay + number_off_instruction_delay = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 -&amp;gt;(duty_percent + 1)*total_number_instruction_to_delay_per_period = number_on_instruction_delay&lt;br /&gt;
&lt;br /&gt;
Of course a few other numbers will have to be adjusted, such as the number of samples to read from memory. Because it has to read in 4 bytes of data, this will end up being:&lt;br /&gt;
 total_number_instructions_to_delay_per_period*4+4&lt;br /&gt;
This way the number will reset to 0 as soon as it goes over the limit of memory to be read.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
During the project we were able to get an approximated 880Hz sine wave to play by changing a pulse width modulation duty cycle to approximate a dc voltage output, as you would with an LED dimmer. You can view this in action along with a helpful tip in the youtube video: &lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=6ytju0bkkiQ&amp;amp;feature=youtu.be PWM Demo].&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
In the first examples, you can see that the GPIO can be toggled on and off simply by editing locations in memory from the PRU. You simply set how long you want the LED to be on and how long you want the LED to be off, and delay the time between on and off to create the desired latency.&lt;br /&gt;
&lt;br /&gt;
In the following example, the premise changes slightly. The operation of our code is simple, the PRU offers precise instruction delay of 5ns per instruction. With this we were able to create a delay of instructions that would be a sampling frequency, and in between this delay of instructions we were able to have a set amount of instructions for which the GPIO was on, and a set amount where the GPIO was off. Also, memory could be set from a C program, and then read by the PRU. This came in handy when approximating the sine wave because C offers the math.h header file that has the sin function included and can give approximate numbers to send to the PRU. The amount of delay on and off could be set dynamically every time the loop began by reading the next bit of data stored in memory, thus creating an average voltage that approximated a playable sine wave.&lt;br /&gt;
&lt;br /&gt;
Refer to How the C Code Works, How the Assembly Code Works, and Building and Running Sin_Approximation for more details.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
For future work there are a few interesting features that we were not able to get to due to time limit and the amount of research needed to begin with. First, we found difficulty in accessing things such as the PWM and analog in ports. These could be further explored given the documents that we have dug up, and some exploration on Google. Second, we wanted to read audio from the analog input and adjust the duty_cycle of the PWM accordingly to have approximate audio output which is the next step to what we have done here. Third, we wanted to explore interrupts on the PRU, but were unable to find enough documentation to get an example working. So, PWM, analog in, audio capabilities, and interrupts are the possible things to look into. Also, any other time critical operations can be explored further with the BeagleBone PRU because it has a delay of exactly 5ns for every instruction.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
So, if you need precise timing, or more rapid access to a certain GPIO pin, this is a rout you might want to look into. There are a few suggestions listed above that might be interesting to see come out of using the PRU. However, if you do not require precisely timed events or faster access to GPIO pins, you might want to consider just using C on the main processor. Much of the information needed to access certain parts of the PRU and the hardware from the PRU is either very vague, or very difficult to dig up, and because the PRU is not widely used, it is difficult to find people that can offer information on the topic.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-02T15:50:08Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Installation Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: Some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
This activates the PRU so that its memory and all of its components are accessible.&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 and turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t/fs) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t/fs)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t/fs)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated due to precise measuring for the sampling frequency, but because this is being run on PRU0, DRAM starts at 0x0. If you feel that you need to change the sampling frequency at any point here's a bit on how to calculate the amount of instructions you need to delay in total.&lt;br /&gt;
&lt;br /&gt;
 sample_period = 1/sample_frequency&lt;br /&gt;
 .&lt;br /&gt;
 sample_period/(number_instructions_delay_loop*5ns) = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 Then count the amount of instructions before or after the loop and nock off that many instructions to delay. This will of course&lt;br /&gt;
 need to be accounted for in the duty cycle, and some sampling frequencies may not offer all duty_percentages.&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = number_on_instruction_delay/number_off_instruction_delay&lt;br /&gt;
 .&lt;br /&gt;
 number_on_instruction_delay + number_off_instruction_delay = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 -&amp;gt;(duty_percent + 1)*total_number_instruction_to_delay_per_period = number_on_instruction_delay&lt;br /&gt;
&lt;br /&gt;
Of course a few other numbers will have to be adjusted, such as the number of samples to read from memory. Because it has to read in 4 bytes of data, this will end up being:&lt;br /&gt;
 total_number_instructions_to_delay_per_period*4+4&lt;br /&gt;
This way the number will reset to 0 as soon as it goes over the limit of memory to be read.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
During the project we were able to get an approximated 880Hz sine wave to play by changing a pulse width modulation duty cycle to approximate a dc voltage output, as you would with an LED dimmer. You can view this in action along with a helpful tip in the youtube video: &lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=6ytju0bkkiQ&amp;amp;feature=youtu.be PWM Demo].&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
In the first examples, you can see that the GPIO can be toggled on and off simply by editing locations in memory from the PRU. You simply set how long you want the LED to be on and how long you want the LED to be off, and delay the time between on and off to create the desired latency.&lt;br /&gt;
&lt;br /&gt;
In the following example, the premise changes slightly. The operation of our code is simple, the PRU offers precise instruction delay of 5ns per instruction. With this we were able to create a delay of instructions that would be a sampling frequency, and in between this delay of instructions we were able to have a set amount of instructions for which the GPIO was on, and a set amount where the GPIO was off. Also, memory could be set from a C program, and then read by the PRU. This came in handy when approximating the sine wave because C offers the math.h header file that has the sin function included and can give approximate numbers to send to the PRU. The amount of delay on and off could be set dynamically every time the loop began by reading the next bit of data stored in memory, thus creating an average voltage that approximated a playable sine wave.&lt;br /&gt;
&lt;br /&gt;
Refer to How the C Code Works, How the Assembly Code Works, and Building and Running Sin_Approximation for more details.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
For future work there are a few interesting features that we were not able to get to due to time limit and the amount of research needed to begin with. First, we found difficulty in accessing things such as the PWM and analog in ports. These could be further explored given the documents that we have dug up, and some exploration on Google. Second, we wanted to read audio from the analog input and adjust the duty_cycle of the PWM accordingly to have approximate audio output which is the next step to what we have done here. Third, we wanted to explore interrupts on the PRU, but were unable to find enough documentation to get an example working. So, PWM, analog in, audio capabilities, and interrupts are the possible things to look into. Also, any other time critical operations can be explored further with the BeagleBone PRU because it has a delay of exactly 5ns for every instruction.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
So, if you need precise timing, or more rapid access to a certain GPIO pin, this is a rout you might want to look into. There are a few suggestions listed above that might be interesting to see come out of using the PRU. However, if you do not require precisely timed events or faster access to GPIO pins, you might want to consider just using C on the main processor. Much of the information needed to access certain parts of the PRU and the hardware from the PRU is either very vague, or very difficult to dig up, and because the PRU is not widely used, it is difficult to find people that can offer information on the topic.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-02T15:49:06Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Executive Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
This activates the PRU so that its memory and all of its components are accessible.&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 and turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t/fs) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t/fs)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t/fs)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated due to precise measuring for the sampling frequency, but because this is being run on PRU0, DRAM starts at 0x0. If you feel that you need to change the sampling frequency at any point here's a bit on how to calculate the amount of instructions you need to delay in total.&lt;br /&gt;
&lt;br /&gt;
 sample_period = 1/sample_frequency&lt;br /&gt;
 .&lt;br /&gt;
 sample_period/(number_instructions_delay_loop*5ns) = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 Then count the amount of instructions before or after the loop and nock off that many instructions to delay. This will of course&lt;br /&gt;
 need to be accounted for in the duty cycle, and some sampling frequencies may not offer all duty_percentages.&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = number_on_instruction_delay/number_off_instruction_delay&lt;br /&gt;
 .&lt;br /&gt;
 number_on_instruction_delay + number_off_instruction_delay = total_number_instructions_to_delay_per_period&lt;br /&gt;
 .&lt;br /&gt;
 -&amp;gt;(duty_percent + 1)*total_number_instruction_to_delay_per_period = number_on_instruction_delay&lt;br /&gt;
&lt;br /&gt;
Of course a few other numbers will have to be adjusted, such as the number of samples to read from memory. Because it has to read in 4 bytes of data, this will end up being:&lt;br /&gt;
 total_number_instructions_to_delay_per_period*4+4&lt;br /&gt;
This way the number will reset to 0 as soon as it goes over the limit of memory to be read.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
During the project we were able to get an approximated 880Hz sine wave to play by changing a pulse width modulation duty cycle to approximate a dc voltage output, as you would with an LED dimmer. You can view this in action along with a helpful tip in the youtube video: &lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=6ytju0bkkiQ&amp;amp;feature=youtu.be PWM Demo].&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
In the first examples, you can see that the GPIO can be toggled on and off simply by editing locations in memory from the PRU. You simply set how long you want the LED to be on and how long you want the LED to be off, and delay the time between on and off to create the desired latency.&lt;br /&gt;
&lt;br /&gt;
In the following example, the premise changes slightly. The operation of our code is simple, the PRU offers precise instruction delay of 5ns per instruction. With this we were able to create a delay of instructions that would be a sampling frequency, and in between this delay of instructions we were able to have a set amount of instructions for which the GPIO was on, and a set amount where the GPIO was off. Also, memory could be set from a C program, and then read by the PRU. This came in handy when approximating the sine wave because C offers the math.h header file that has the sin function included and can give approximate numbers to send to the PRU. The amount of delay on and off could be set dynamically every time the loop began by reading the next bit of data stored in memory, thus creating an average voltage that approximated a playable sine wave.&lt;br /&gt;
&lt;br /&gt;
Refer to How the C Code Works, How the Assembly Code Works, and Building and Running Sin_Approximation for more details.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
For future work there are a few interesting features that we were not able to get to due to time limit and the amount of research needed to begin with. First, we found difficulty in accessing things such as the PWM and analog in ports. These could be further explored given the documents that we have dug up, and some exploration on Google. Second, we wanted to read audio from the analog input and adjust the duty_cycle of the PWM accordingly to have approximate audio output which is the next step to what we have done here. Third, we wanted to explore interrupts on the PRU, but were unable to find enough documentation to get an example working. So, PWM, analog in, audio capabilities, and interrupts are the possible things to look into. Also, any other time critical operations can be explored further with the BeagleBone PRU because it has a delay of exactly 5ns for every instruction.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
So, if you need precise timing, or more rapid access to a certain GPIO pin, this is a rout you might want to look into. There are a few suggestions listed above that might be interesting to see come out of using the PRU. However, if you do not require precisely timed events or faster access to GPIO pins, you might want to consider just using C on the main processor. Much of the information needed to access certain parts of the PRU and the hardware from the PRU is either very vague, or very difficult to dig up, and because the PRU is not widely used, it is difficult to find people that can offer information on the topic.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-01T23:38:41Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Building and Running the Sin_Approximation Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t)&lt;br /&gt;
&lt;br /&gt;
Looking at the assembly code, we see a similar PWM control as before, but this time it is reading the duty cycles from memory. The coding to do this is a little more complicated, but because this is being run on PRU0, DRAM starts at 0x0.&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-01T22:21:48Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Building and Running the Sin_Approximation Example ==&lt;br /&gt;
&lt;br /&gt;
This example uses a modified version of the GPIO_PWM_PRU example to change the duty cycle every period such that the average voltage approximates a sin wave. Navigate to the pwm_sin directory and take a look at the C code. Its nearly identical to the previous code except for a few small differences. The first difference is that it opens and edits two files to export GPIO0_7 turn it into an output.&lt;br /&gt;
&lt;br /&gt;
The next change is that the prussdrv_pru_write_memory command discussed above is used to push an array containing duty cycles onto the DRAM for PRU0. The duty cycles are approximated using a the sin function from the math.h header file. Here is why:&lt;br /&gt;
 (VCC*(on_time)+0*(off_time))   &lt;br /&gt;
 ---------------------------- = VCC*duty_percent&lt;br /&gt;
            period&lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = Va&lt;br /&gt;
 .&lt;br /&gt;
 Va = VCC*Sin(2*PI*f*t) &lt;br /&gt;
 .&lt;br /&gt;
 VCC*duty_percent = VCC*sin(2*PI*f*t)&lt;br /&gt;
 .&lt;br /&gt;
 duty_percent = sin(2*PI*f*t)&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-01T21:58:41Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How the C Code Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
The next section waits on event 0 from the PRU to signal the C program that it has completed its execution. This, again, was not implemented, but writing the appropriate bit to the r31 register would cause the C program to continue. As it is, the program stalls at this point until SIGINT is received. &lt;br /&gt;
&lt;br /&gt;
If the correct event were received, the next function is used to halt the PRU's execution then it would release the PRUSS clocks and disable the prussdrv module.&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-01T21:47:18Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How the C Code Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
The code first initializes the PRUSS by allocating memory for it using the prussdrv_init() function. It then initializes memory mapping for the PRU using the prussdrv_open() function. All of the intc functions are used for interrupt communication between the ARM and the PRU. This code is not utilized by the examples in this page. There is more information about using interrupts available in the '''Interrupts''' section below.&lt;br /&gt;
&lt;br /&gt;
Similar to the exec function in C, the  prussdrv_exec_program () function overlays the IRAM (Instruction RAM) portion of the PRUSS with the bin file that was created from blinker.p. The first field of prussdrv_exec_program needs a PRU number, which is either 0 or 1 depending on which PRU core is being used. In this case, PRU0 is executing blinker.bin. The second field is the path to the bin that will be put into the PRU's IRAM.&lt;br /&gt;
&lt;br /&gt;
'''FILL THIS IN LATER'''&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-11-01T21:36:19Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How the C Code Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 2 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown where V1 is your pwm voltage, V2 is your -1.65V bias, and V3 is unused:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
The blinker.c file is a direct port of the PRU initialization code from TI. Putting the two side by side, the only difference between the two is the name of the bin file that is used for the exec function.&lt;br /&gt;
&lt;br /&gt;
'''FILL THIS IN LATER'''&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-30T21:37:48Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Sending an array to the PRU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 3 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
'''FILL THIS IN LATER'''&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
wordoffset is an offset in words (4 bytes) from the base memory location, pru_ram_id. &lt;br /&gt;
&lt;br /&gt;
memarea is a pointer to an array of unsigned ints (also 4 bytes) that will be passed onto the PRU.&lt;br /&gt;
&lt;br /&gt;
bytelength is the number of bytes to write to the PRU.&lt;br /&gt;
&lt;br /&gt;
For more information on using C to initialize the PRU visit [http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem TI's PRU Linux Application Loader API Guide]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-30T21:29:47Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Sending an array to the PRU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 3 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
'''FILL THIS IN LATER'''&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
  int prussdrv_pru_write_memory (unsigned int pru_ram_id, unsigned int wordoffset, unsigned int *memarea,  unsigned int bytelength); &lt;br /&gt;
&lt;br /&gt;
pru_ram_id can take on one of 4 values, and are as follows:&lt;br /&gt;
&lt;br /&gt;
 PRUSS0_PRU0_DATARAM &lt;br /&gt;
 PRUSS0_PRU1_DATARAM &lt;br /&gt;
 PRUSS0_PRU0_IRAM &lt;br /&gt;
 PRUSS0_PRU1_IRAM&lt;br /&gt;
&lt;br /&gt;
Here, each of the PRUs have both an Instruction RAM and a DATARAM section. DATARAM for PRU0 is found in the memory locations 0x0 - 0x2000, and DATARAM for PRU1 iis found in the memory locations 0x2000 - 0x4000. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-30T21:24:40Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
For this project, the objective is to explore the PRU of the BeagleBone, looking at both the limitations of implementation and how to implement tasks such as handling pulse width modulation. The project is more research intensive, as opposed to implementation intensive, and serves to bring together all of the sources found on the BeagleBone's PRU into one abbreviated document with examples of how to use it and the potential for extra projects. The ultimate goal here is to walk through step by step leading to the representation of a sinusoidal wave using pulse width modulation accessed from PRU and play the produced wave through a speaker.&lt;br /&gt;
&lt;br /&gt;
As of now we have gathered information about the PRU, found memory locations that can be edited on the PRU and in C so that we can interact with functions outside of the PRU's capabilities, and implemented code on the PRU that simulates a pulse width modulation on a GPIO pin.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
*Actual PWM implementation&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
The Git Hub is on the following link:  &lt;br /&gt;
&lt;br /&gt;
*https://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
*Hardware: A push button for input and, though not necessarily required, some LEDs for messing with the GPIO pins and a speaker for listening to PWM approximated sine wave.&lt;br /&gt;
&lt;br /&gt;
Note: When implementing the pulse width modulation, you may want to bias the wave around 0V instead of 1.65V. If this is the case, you may want to use a summer circui which will require an Op-Amp, a 2kohm and 1kohm resistor, and 3 resistors of the same value (Higher values preferable for lower power consumption), which will need to be connected as shown:&lt;br /&gt;
&lt;br /&gt;
[[File:SummerCicuit.png|Non-Inverting Summer Circuit]]&lt;br /&gt;
&lt;br /&gt;
Unless you desire a louder output than capable with simple I/O pins, there is no additional hardware needed.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Finding Where to Access Things ==&lt;br /&gt;
&lt;br /&gt;
There are many locations in memory that are needed to access specific I/O pins on the BeagleBone. Some of these I/O pins can be found here:&lt;br /&gt;
*[http://www.ti.com/lit/ug/spruh73f/spruh73f.pdf SPRUH73f pdf]&lt;br /&gt;
&lt;br /&gt;
The following are not found in the file, but are good addresses to know when accessing MUXs:&lt;br /&gt;
&lt;br /&gt;
gpmc_a2:&lt;br /&gt;
 memory location: gpmc_a2.gpio1_18 (0x44e10848/0x848 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a2 | gmii2_txd3 | rgmii2_td3 | mmc2_dat1 | gpmc_a18 | pr1_mii1_txd2 | ehrpwm1A | gpio1_18&lt;br /&gt;
&lt;br /&gt;
gpmc_a3:&lt;br /&gt;
 memory location: gpmc_a3.gpio1_19 (0x44e1084c/0x84c = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_a3 | gmii2_txd2 | rgmii2_td2 | mmc2_dat2 | gpmc_a19 | pr1_mii1_txd1 | ehrpwm1B | gpio1_19&lt;br /&gt;
&lt;br /&gt;
gpmc_ad8:&lt;br /&gt;
 memory location: gpmc_ad8.gpio0_22 (0x44e10820/0x820 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad8 | lcd_data23 | mmc1_dat0 | mmc2_dat4 | ehrpwm2A | pr1_mii_mt0_clk | NA | gpio0_22&lt;br /&gt;
&lt;br /&gt;
gpmc_ad9:&lt;br /&gt;
 memory location: gpmc_ad9.gpio0_23 (0x44e10824/0x824 = 0x0027), b NA, t NA&lt;br /&gt;
 mode: OMAP_PIN_INPUT_PULLDOWN | OMAP_MUX_MODE7&lt;br /&gt;
 signals: gpmc_ad9 | lcd_data22 | mmc1_dat1 | mmc2_dat5 | ehrpwm2B | pr1_mii0_col | NA | gpio0_23&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
'''FILL THIS IN LATER'''&lt;br /&gt;
&lt;br /&gt;
== Sending an array to the PRU ==&lt;br /&gt;
&lt;br /&gt;
The initialization code provided by TI has a handy function for passing an array to the PRU. Each of the PRU cores have an 8kb data ram associated with them, and that data space can be populated from an external C program. The next example will make use of this function to pass different PWM duty cycles to the PRU. This will be largely based around the following function:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T17:17:53Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== How the C Code Works ==&lt;br /&gt;
&lt;br /&gt;
'''FILL THIS IN LATER'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T17:16:44Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How the Assembly Code Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T17:11:23Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How it Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How it Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU's Assembly Instructions] from TI&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T17:08:31Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How it Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the [http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions Guide from TI]&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T17:07:26Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How it Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How it Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives the following for for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
These equations can be used to create a very exact PWM output by setting duty_cycle and period to the values you wish to use. The code that was compiled and run above has a period of about a second and a duty cycle of about 50%.&lt;br /&gt;
&lt;br /&gt;
There are a few macros defined at the beginning of the program. These macros are the location of GPIO1's memory space, the location of its set registers and the location of its clear registers. The BeagleBone's GPIO pins must be turned off and on using these two different memory locations. Setting the set register to 0 does not turn off its respective GPIO pin.&lt;br /&gt;
&lt;br /&gt;
r2 stores the value that is going to be written to either set or clear gpio. r3 sores the address that r2 will be written to. within the first 3 lines of PWM_ON these values are set such that r2 will turn on the user LEDs. The instruction that actually turns it on is SBBO. This takes the value of r2 and writes it to memory location r3 with an offset of 0.&lt;br /&gt;
&lt;br /&gt;
Here is a complete guide to the&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T16:53:24Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* How it Works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How it Works ==&lt;br /&gt;
&lt;br /&gt;
//in the overview talk about the period being 5ns&lt;br /&gt;
&lt;br /&gt;
Registers r5 and r6 are the duty_cycle and period respectively. The duty_cycle is a number smaller than the period that the accumulator r4 counts up to before setting the output to zero. When the r4 = period, r4 resets and the output is set to 1. This gives a very nearly even number of instructions for OnTime and OffTime.&lt;br /&gt;
&lt;br /&gt;
 SecondsPerCycle = 5*10^-9&lt;br /&gt;
 OnCycles = 2 + (duty_cycle)*3 + 2&lt;br /&gt;
 OffCycles = 2 + (period - duty_cycle)*3 - 1 + 2&lt;br /&gt;
 TotalCycles = 7 + (period)*3&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T16:27:01Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== How it Works ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T16:24:06Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Building and Running the GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T16:22:37Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE is specified as &amp;quot;&amp;quot; because this is running on the BeagleBone itself and the Makefile is setup to defaultly cross compile the code from another linux machine.&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included with any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. Navigate to the example's root directory again:&lt;br /&gt;
 cd ../../&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will compile the blinker.c file and output it to the bin folder. After this point, the assembly file needs to be compiled into a .bin file. This is done in the bin folder.&lt;br /&gt;
 cd bin&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Now, there should be a blinker.bin file in the folder. running the blinker executabile will put the blinker.bin file on the PRU and start it running. Use the following:&lt;br /&gt;
 ./blinker&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T16:15:25Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== GPIO_PWM_PRU Example ==&lt;br /&gt;
&lt;br /&gt;
This example is located in the GPIO_PWM_PRU directory in the AM335x_PRU_BeagleBone git repository, and can be pulled with the following:&lt;br /&gt;
 git clone git://github.com/millerap/AM335x_PRU_BeagleBone&lt;br /&gt;
&lt;br /&gt;
This example uses the gpio and delay loops to approximate a PWM using the user LEDs on the BeagleBone. It is based on an example provided by Lyren Brown and documented by boxysean at &lt;br /&gt;
 http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/&lt;br /&gt;
&lt;br /&gt;
In GPIO_PWM_PRU all of the complicated Makefiles and directories used to make a multitude of examples at once have been stripped away to allow the user to compile one individual program that will run on the PRU.&lt;br /&gt;
&lt;br /&gt;
The readme.txt file in the GPIO_PWM_PRU directory provides a walkthrough for compiling and running blinker on the BeagleBone.&lt;br /&gt;
&lt;br /&gt;
The first step to compiling a program for the PRU is to make sure prussdrv.c is made and up to date. This is the file provided by TI that contains all of the C functions that allow for communication with the PRU. To do this, do the following:&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;/AM335x_PRU_BeagleBone/GPIO_PWM_PRU/interface&lt;br /&gt;
 make CROSS_COMPILE=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Once this is completed, the pasm_source must be set for the BeagleBone's linux operating system:&lt;br /&gt;
 cd ../utils/pasm_source&lt;br /&gt;
 ./linuxbuild&lt;br /&gt;
&lt;br /&gt;
'''Note: The above instructions need to be done for every time the BeagleBone boots up and these directories should be included in any code that you write for the PRU'''&lt;br /&gt;
&lt;br /&gt;
Now, the BeagleBone is ready to compile the example code. &lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/ECE497_BeagleBone_PRU</id>
		<title>ECE497 BeagleBone PRU</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/ECE497_BeagleBone_PRU"/>
				<updated>2012-10-25T15:50:44Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* User Instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497 |Project]]&lt;br /&gt;
{{YoderHead}}&lt;br /&gt;
&lt;br /&gt;
Team members: [[user:Yoder|Mark A. Yoder]], [[user:Correlbn|Bryan Correll]], [[user:Millerap|Andrew Miller]], [[user:Ngop|Peter Ngo]], [[user:Popenhjc|James Popenhagen]]&lt;br /&gt;
&lt;br /&gt;
== Executive Summary ==&lt;br /&gt;
&lt;br /&gt;
Give two sentence intro to the project.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what works.&lt;br /&gt;
&lt;br /&gt;
Give two sentences telling what isn't working.&lt;br /&gt;
&lt;br /&gt;
End with a two sentence conclusion.&lt;br /&gt;
&lt;br /&gt;
The sentence count is approximate and only to give an idea of the expected length.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
Give step by step instructions on how to install your project on the SPEd2 image.  &lt;br /&gt;
&lt;br /&gt;
* Include your [https://github.com/ github] path as a link like this:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].  &lt;br /&gt;
* Include any additional packages installed via '''opkg'''.&lt;br /&gt;
* Include kernel mods.&lt;br /&gt;
* If there is extra hardware needed, include links to where it can be obtained.&lt;br /&gt;
&lt;br /&gt;
== User Instructions ==&lt;br /&gt;
&lt;br /&gt;
'''Always''' run the following before doing anything with the PRU:&lt;br /&gt;
 beagle$ '''modprobe uio_pruss'''&lt;br /&gt;
&lt;br /&gt;
== Highlights ==&lt;br /&gt;
&lt;br /&gt;
Here is where you brag about what your project can do.&lt;br /&gt;
&lt;br /&gt;
Include a [http://www.youtube.com/ YouTube] demo.&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==&lt;br /&gt;
&lt;br /&gt;
Give a high level overview of the structure of your software.  Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.&lt;br /&gt;
&lt;br /&gt;
== Work Breakdown ==&lt;br /&gt;
&lt;br /&gt;
Milestones&lt;br /&gt;
&lt;br /&gt;
10/22: We should have all research done. Update documentation with every Milestone.&lt;br /&gt;
&lt;br /&gt;
10/26: We should be able to show something, an example or simple implementation.&lt;br /&gt;
&lt;br /&gt;
10/29: Ability to send different lengths to turn on an LEDs.&lt;br /&gt;
&lt;br /&gt;
10/31: Ability to send different lengths to multiple LEDs.&lt;br /&gt;
&lt;br /&gt;
11/2: We should be able to demo our overall work, possibly have some things to fix before presentation.&lt;br /&gt;
&lt;br /&gt;
11/4: Finalize presentation&lt;br /&gt;
&lt;br /&gt;
11/6: Presentation&lt;br /&gt;
&lt;br /&gt;
Research&lt;br /&gt;
&lt;br /&gt;
Most of our research has come from internet resources listed below:&lt;br /&gt;
*[http://elinux.org/Ti_AM33XX_PRUSSv2 TI PRU Resources]&lt;br /&gt;
*[http://blog.boxysean.com/2012/08/12/first-steps-with-the-beaglebone-pru/ Example for Running Code on the PRU]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions PRU Assembly Instructions]&lt;br /&gt;
*[http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide#prussdrv_map_prumem Initializing PRU in C]&lt;br /&gt;
*[http://www.ti.com/lit/ds/symlink/am3358.pdf AM335X Datasheet]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
Suggest addition things that could be done with this project.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.&lt;br /&gt;
&lt;br /&gt;
{{YoderFoot}}&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-05T13:37:52Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. To test this operation, I hooked up an IR LED to a function generator set to a 38kHz square wave. The function generator created the carrier frequency required to the receiver to recognize it. I hooked up the VDD pin of the IR Receiver to a 5 volt source limited to 100 mA, and i hooked up the output pin to an oscilloscope. When the function generator's output was turned on, the IR Receiver's output went low, and when it was shut off again, the output value went high. &lt;br /&gt;
&lt;br /&gt;
Next, the same sort of experiment was performed using a BeagleBone. The BeagleBone's built in PWM outputs can be set to act the same as the 38kHz square wave created by the function generator. How to set this up will be detailed below. The same IR LED was then hooked up to the BeagleBone's PWM output, and the PWM was set to run with a frequency of 38kHz and duty cycle of 50%. This also caused the output on the oscilloscope to read a zero when turned on. &lt;br /&gt;
&lt;br /&gt;
To set up and use the PWM, I used '''ehrpwm1:0''', which is located on pin 6 of mux '''gpmc_a2'''. '''gpmc_a2''' is located on pin 14 of the BeagleBone, and has pin 7 of the mux enabled by default. To change the enabled pin of '''gpmc_a2''' you must change the value stored in the file /sys/kernel/debug/omap_mux/gpmc_a2 on the BeagleBone from 7 to 6. The directory /sys/kernel/debug/omap_mux contains all of the muxes on the BeagleBone, and any one of them can be changed by writing into their respective files.&lt;br /&gt;
&lt;br /&gt;
Once '''ehrpwm1:0''' is enabled on pin 14, its frequency and duty cycle must be set. By writing 38000 into /sys/class/pwm/ehrpwm1:0/duty_freq, we can set the frequency to 38kHz, and by writing 50 into /sys/class/pwm/ehrpwm1:0/duty_cycle, we can set the duty cycle to 50%. This will result in a 38kHz squarewave on the output when /sys/class/pwm/ehrpwm1:0/run is set to 1.&lt;br /&gt;
&lt;br /&gt;
'''Note that once a duty_cycle is set, /sys/class/pwm/ehrpwm1:0/duty_ns should be set to 0 to change the duty_freq'''&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Wiring''' ==&lt;br /&gt;
&lt;br /&gt;
These following diagram shows how to wire the BeagleBone to reproduce my testing procedure.&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring Diagram for IR Sensor.png|400px| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. My code used all of the setup described above to setup a 38kHz square wave on ehrpwm1:0. I used a bitrate of 1kHz to transmit, meaning that every 1ms I toggled the PWM either on or off depending on the next bit of the 'c' I was transmitting. This involved using a usleep(1000) to wait 1ms between toggles. With an 8-bit char, that gives a character transmit rate of 125Hz (1kHz/8bits = 125Hz). While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:Wiring_Diagram_for_IR_Sensor.png</id>
		<title>File:Wiring Diagram for IR Sensor.png</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:Wiring_Diagram_for_IR_Sensor.png"/>
				<updated>2012-10-05T13:36:11Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: wiring diagram for sparkfun's TSOP85338 IR Sensor&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;wiring diagram for sparkfun's TSOP85338 IR Sensor&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-05T13:17:03Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. To test this operation, I hooked up an IR LED to a function generator set to a 38kHz square wave. The function generator created the carrier frequency required to the receiver to recognize it. I hooked up the VDD pin of the IR Receiver to a 5 volt source limited to 100 mA, and i hooked up the output pin to an oscilloscope. When the function generator's output was turned on, the IR Receiver's output went low, and when it was shut off again, the output value went high. &lt;br /&gt;
&lt;br /&gt;
Next, the same sort of experiment was performed using a BeagleBone. The BeagleBone's built in PWM outputs can be set to act the same as the 38kHz square wave created by the function generator. How to set this up will be detailed below. The same IR LED was then hooked up to the BeagleBone's PWM output, and the PWM was set to run with a frequency of 38kHz and duty cycle of 50%. This also caused the output on the oscilloscope to read a zero when turned on. &lt;br /&gt;
&lt;br /&gt;
To set up and use the PWM, I used '''ehrpwm1:0''', which is located on pin 6 of mux '''gpmc_a2'''. '''gpmc_a2''' is located on pin 14 of the BeagleBone, and has pin 7 of the mux enabled by default. To change the enabled pin of '''gpmc_a2''' you must change the value stored in the file /sys/kernel/debug/omap_mux/gpmc_a2 on the BeagleBone from 7 to 6. The directory /sys/kernel/debug/omap_mux contains all of the muxes on the BeagleBone, and any one of them can be changed by writing into their respective files.&lt;br /&gt;
&lt;br /&gt;
Once '''ehrpwm1:0''' is enabled on pin 14, its frequency and duty cycle must be set. By writing 38000 into /sys/class/pwm/ehrpwm1:0/duty_freq, we can set the frequency to 38kHz, and by writing 50 into /sys/class/pwm/ehrpwm1:0/duty_cycle, we can set the duty cycle to 50%. This will result in a 38kHz squarewave on the output when /sys/class/pwm/ehrpwm1:0/run is set to 1.&lt;br /&gt;
&lt;br /&gt;
'''Note that once a duty_cycle is set, /sys/class/pwm/ehrpwm1:0/duty_ns should be set to 0 to change the duty_freq'''&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Wiring''' ==&lt;br /&gt;
&lt;br /&gt;
These following diagram shows how to wire the BeagleBone to reproduce my testing procedure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. My code used all of the setup described above to setup a 38kHz square wave on ehrpwm1:0. I used a bitrate of 1kHz to transmit, meaning that every 1ms I toggled the PWM either on or off depending on the next bit of the 'c' I was transmitting. This involved using a usleep(1000) to wait 1ms between toggles. With an 8-bit char, that gives a character transmit rate of 125Hz (1kHz/8bits = 125Hz). While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T15:27:20Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Testing and Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. To test this operation, I hooked up an IR LED to a function generator set to a 38kHz square wave. The function generator created the carrier frequency required to the receiver to recognize it. I hooked up the VDD pin of the IR Receiver to a 5 volt source limited to 100 mA, and i hooked up the output pin to an oscilloscope. When the function generator's output was turned on, the IR Receiver's output went low, and when it was shut off again, the output value went high. &lt;br /&gt;
&lt;br /&gt;
Next, the same sort of experiment was performed using a BeagleBone. The BeagleBone's built in PWM outputs can be set to act the same as the 38kHz square wave created by the function generator. How to set this up will be detailed below. The same IR LED was then hooked up to the BeagleBone's PWM output, and the PWM was set to run with a frequency of 38kHz and duty cycle of 50%. This also caused the output on the oscilloscope to read a zero when turned on. &lt;br /&gt;
&lt;br /&gt;
To set up and use the PWM, I used '''ehrpwm1:0''', which is located on pin 6 of mux '''gpmc_a2'''. '''gpmc_a2''' is located on pin 14 of the BeagleBone, and has pin 7 of the mux enabled by default. To change the enabled pin of '''gpmc_a2''' you must change the value stored in the file /sys/kernel/debug/omap_mux/gpmc_a2 on the BeagleBone from 7 to 6. The directory /sys/kernel/debug/omap_mux contains all of the muxes on the BeagleBone, and any one of them can be changed by writing into their respective files.&lt;br /&gt;
&lt;br /&gt;
Once '''ehrpwm1:0''' is enabled on pin 14, its frequency and duty cycle must be set. By writing 38000 into /sys/class/pwm/ehrpwm1:0/duty_freq, we can set the frequency to 38kHz, and by writing 50 into /sys/class/pwm/ehrpwm1:0/duty_cycle, we can set the duty cycle to 50%. This will result in a 38kHz squarewave on the output when /sys/class/pwm/ehrpwm1:0/run is set to 1.&lt;br /&gt;
&lt;br /&gt;
'''Note that once a duty_cycle is set, /sys/class/pwm/ehrpwm1:0/duty_ns should be set to 0 to change the duty_freq'''&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. My code used all of the setup described above to setup a 38kHz square wave on ehrpwm1:0. I used a bitrate of 1kHz to transmit, meaning that every 1ms I toggled the PWM either on or off depending on the next bit of the 'c' I was transmitting. This involved using a usleep(1000) to wait 1ms between toggles. With an 8-bit char, that gives a character transmit rate of 125Hz (1kHz/8bits = 125Hz). While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T15:22:34Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Sending a Signal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. To test this operation, I hooked up an IR LED to a function generator set to a 38kHz square wave. The function generator created the carrier frequency required to the receiver to recognize it. I hooked up the VDD pin of the IR Receiver to a 5 volt source limited to 100 mA, and i hooked up the output pin to an oscilloscope. When the function generator's output was turned on, the IR Receiver's output went low, and when it was shut off again, the output value went high. &lt;br /&gt;
&lt;br /&gt;
Next, the same sort of experiment was performed using a BeagleBone. The BeagleBone's built in PWM outputs can be set to act the same as the 38kHz square wave created by the function generator. How to set this up will be detailed below. The same IR LED was then hooked up to the BeagleBone's PWM output, and the PWM was set to run with a frequency of 38kHz and duty cycle of 50%. This also caused the output on the oscilloscope to read a zero when turned on. &lt;br /&gt;
&lt;br /&gt;
To set up and use the PWM, I used '''ehrpwm1:0''', which is located on pin 6 of mux '''gpmc_a2'''. '''gpmc_a2''' is located on pin 14 of the BeagleBone, and has pin 7 of the mux enabled by default. To change the enabled pin of '''gpmc_a2''' you must change the value stored in the file /sys/kernel/debug/omap_mux/gpmc_a2 on the BeagleBone from 7 to 6. The directory /sys/kernel/debug/omap_mux contains all of the muxes on the BeagleBone, and any one of them can be changed by writing into their respective files.&lt;br /&gt;
&lt;br /&gt;
Once '''ehrpwm1:0''' is enabled on pin 14, its frequency and duty cycle must be set. By writing 38000 into /sys/class/pwm/ehrpwm1:0/duty_freq, we can set the frequency to 38kHz, and by writing 50 into /sys/class/pwm/ehrpwm1:0/duty_cycle, we can set the duty cycle to 50%. This will result in a 38kHz squarewave on the output when /sys/class/pwm/ehrpwm1:0/run is set to 1.&lt;br /&gt;
&lt;br /&gt;
'''Note that once a duty_cycle is set, /sys/class/pwm/ehrpwm1:0/duty_ns should be set to 0 to change the duty_freq'''&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T15:19:11Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Sending a Signal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. To test this operation, I hooked up an IR LED to a function generator set to a 38kHz square wave. The function generator created the carrier frequency required to the receiver to recognize it. I hooked up the VDD pin of the IR Receiver to a 5 volt source limited to 100 mA, and i hooked up the output pin to an oscilloscope. When the function generator's output was turned on, the IR Receiver's output went low, and when it was shut off again, the output value went high. &lt;br /&gt;
&lt;br /&gt;
Next, the same sort of experiment was performed using a BeagleBone. The BeagleBone's built in PWM outputs can be set to act the same as the 38kHz square wave created by the function generator. How to set this up will be detailed below. The same IR LED was then hooked up to the BeagleBone's PWM output, and the PWM was set to run with a frequency of 38kHz and duty cycle of 50%. This also caused the output on the oscilloscope to read a zero when turned on. &lt;br /&gt;
&lt;br /&gt;
To set up and use the PWM, I used '''ehrpwm1:0''', which is located on pin 6 of mux '''gpmc_a2'''. '''gpmc_a2''' is located on pin 14 of the BeagleBone, and has pin 7 of the mux enabled by default. To change the enabled pin of any '''gpmc_a2''' you must change the value stored in the file /sys/kernel/debug/omap_mux/gpmc_a2 on the BeagleBone from 7 to 6. The directory /sys/kernel/debug/omap_mux contains all of the muxes on the BeagleBone, and any one of them can be changed by writing into their respective files.&lt;br /&gt;
&lt;br /&gt;
Once '''ehrpwm1:0''' is enabled on pin 14, its frequency and duty cycle must be set. By writing 38000 into /sys/class/pwm/ehrpwm1:0/duty_freq, we can set the frequency to 38kHz, and by writing 50 into /sys/class/pwm/ehrpwm1:0/duty_cycle, we can set the duty cycle to 50%. This will result in a 38kHz squarewave on the output when /sys/class/pwm/ehrpwm1:0/run is set to 1.&lt;br /&gt;
&lt;br /&gt;
'''Note that once a duty_cycle is set, /sys/class/pwm/ehrpwm1:0/duty_ns should be set to 0 to change the duty_freq'''&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T15:12:13Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Sending a Signal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. To test this operation, I hooked up an IR LED to a function generator set to a 38kHz square wave. The function generator created the carrier frequency required to the receiver to recognize it. I hooked up the VDD pin of the IR Receiver to a 5 volt source limited to 100 mA, and i hooked up the output pin to an oscilloscope. When the function generator's output was turned on, the IR Receiver's output went low, and when it was shut off again, the output value went high. &lt;br /&gt;
&lt;br /&gt;
Next, the same sort of experiment was performed using a BeagleBone. The BeagleBone's built in PWM outputs can be set to act the same as the 38kHz square wave created by the function generator. How to set this up will be detailed below. The same IR LED was then hooked up to the BeagleBone's PWM output, and the PWM was set to run with a frequency of 38kHz and duty cycle of 50%. This also caused the output on the oscilloscope to read a zero when turned on. &lt;br /&gt;
&lt;br /&gt;
To set up and use the PWM, I used '''ehrpwm1:0''', which is located on pin 6 of mux '''gpmc_a2'''. '''gpmc_a2''' is located on pin 14 of the BeagleBone, and has pin 7 of the mux enabled by default. To change the enabled pin of any '''gpmc_a2''' you must change the value stored in the file /sys/debug/kernel/omap_mux/gpmc_a2 on the BeagleBone from 7 to 6.&lt;br /&gt;
&lt;br /&gt;
Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:56:25Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. &lt;br /&gt;
&lt;br /&gt;
Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:52:13Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP85338 is available below.&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. &lt;br /&gt;
&lt;br /&gt;
Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:49:55Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Sending a Signal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP38553 is available below.&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. On a high level, This &lt;br /&gt;
&lt;br /&gt;
Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:48:20Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output, and it can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP38553 is available below.&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:47:11Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output that can be read by a device such as a BeagleBone. Additionally the circuit diagram of the TSOP38553 is available below.&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:44:48Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
The Picture below the one on the left shows the bottom of the IR Receiver. The Receiver needs an external VDD source to power it. This VDD can be varied from 2.5V-5.5V as seen above. The middle pin is the output that can be read by a device such as a BeagleBone.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:41:42Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Pinout Diagram TSOP38553.jpg|200px|left| Bottom side view of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| The Schematic of the TSOP38553]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:Pinout_Diagram_TSOP38553.jpg</id>
		<title>File:Pinout Diagram TSOP38553.jpg</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:Pinout_Diagram_TSOP38553.jpg"/>
				<updated>2012-10-04T14:39:39Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: Pinout diagram for tsop38553 from sparkfun.com&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pinout diagram for tsop38553 from sparkfun.com&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:38:15Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553 Schematic.PNG| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:TSOP38553_Schematic.PNG</id>
		<title>File:TSOP38553 Schematic.PNG</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:TSOP38553_Schematic.PNG"/>
				<updated>2012-10-04T14:36:55Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: Schematic of TSOP38553 from sparkfun.com&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Schematic of TSOP38553 from sparkfun.com&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:30:46Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Background Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Carrier Frequency:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-04T14:25:08Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]]&lt;br /&gt;
[[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
Overview:  0, In your Background section, give details on what the device is.&lt;br /&gt;
What is it able to do? Show a picture of the device that shows what pins it has.&lt;br /&gt;
In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device.&lt;br /&gt;
Describe at a high level what you are doing, then go into the details of how you do it.&lt;br /&gt;
Wiring:   0, Give a specific example of how to wire it.  What pins go where?  &lt;br /&gt;
Which bone header are you using?  P8, P9?  &lt;br /&gt;
Code:     1, Give step by step instructions so it's easy for someone else to reproduce it.&lt;br /&gt;
git:    2&lt;br /&gt;
Demo:     0&lt;br /&gt;
Total:    3/10&lt;br /&gt;
Comments:  More details are needed.  I think someone else in the class would have trouble&lt;br /&gt;
reproducing what you have done.  It looks like your code transmits only.  Have you had any luck&lt;br /&gt;
with receiving on the bone?&lt;br /&gt;
&lt;br /&gt;
Generally functions aren't defined in .h files.  Could you move the functions to a BoneHeader.c file and create &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP85338.jpg|200px|left| Picture of the physical IR Receiver Breakout Board]]&lt;br /&gt;
&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Sample Rate:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/File:TSOP85338.jpg</id>
		<title>File:TSOP85338.jpg</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/File:TSOP85338.jpg"/>
				<updated>2012-10-04T14:23:32Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: an image of the IR Receiver Breakout Board available at sparkfun.com&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;an image of the IR Receiver Breakout Board available at sparkfun.com&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-01T13:19:49Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]][[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Sample Rate:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-10-01T13:19:01Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Testing and Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]][[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
'''This Page is Still Under Construction'''&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Sample Rate:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using PRU''' ==&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-09-29T18:33:16Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Testing and Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]][[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
'''This Page is Still Under Construction'''&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Sample Rate:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
The above figure is the measurement taken of the TSOP38553's rise time.&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using PRU''' ==&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	<entry>
		<id>http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board</id>
		<title>Sparkfun: IR Receiver Breakout Board</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/Sparkfun:_IR_Receiver_Breakout_Board"/>
				<updated>2012-09-29T18:30:13Z</updated>
		
		<summary type="html">&lt;p&gt;Millerap: /* Testing and Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:ECE497]][[Category:SparkFun]]&lt;br /&gt;
&lt;br /&gt;
'''This Page is Still Under Construction'''&lt;br /&gt;
&lt;br /&gt;
== '''Background Information''' ==&lt;br /&gt;
'''Model:''' TSOP85338&lt;br /&gt;
&lt;br /&gt;
'''Sample Rate:''' 38kHz&lt;br /&gt;
&lt;br /&gt;
'''VDD:'''  2.5V-5.5V&lt;br /&gt;
&lt;br /&gt;
== '''Sending a Signal''' ==&lt;br /&gt;
&lt;br /&gt;
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, '''ehrpwm1:0''' can be used. By setting the '''duty_freq''' to 38000 and '''duty_percent''' to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using Interrupts and GPIO''' ==&lt;br /&gt;
&lt;br /&gt;
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on &amp;quot;both&amp;quot; edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.&lt;br /&gt;
&lt;br /&gt;
If working in C, poll.h has some nice tools that can be used to create your interrupts.&lt;br /&gt;
&lt;br /&gt;
'''This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time''' &lt;br /&gt;
&lt;br /&gt;
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.&lt;br /&gt;
&lt;br /&gt;
== '''Testing and Results''' ==&lt;br /&gt;
&lt;br /&gt;
'''All measurements and tests were performed using a 5V source'''&lt;br /&gt;
&lt;br /&gt;
[[File:Wiring-Diagram-for-TSOP38553.JPG|200px|right| Wiring Diagram for use with the C code provided below]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.&lt;br /&gt;
&lt;br /&gt;
The code used to perform this testing is available on github.com. Use the following to download it.&lt;br /&gt;
    git clone https://github.com/millerap/IRReceiverBreakoutBoard&lt;br /&gt;
&lt;br /&gt;
[[File:TSOP38553-Rise-Time-Measurement.jpg|400px|center| Scope measurement of the Rise Time with frequency]]&lt;br /&gt;
&lt;br /&gt;
[[File:Annotated-Scope-Output-of-TSOP38553.jpg|400px|center| Scope measurement showing input and output as a 'c' char is shifted out.]]&lt;br /&gt;
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.&lt;br /&gt;
&lt;br /&gt;
== '''Reading Using PRU''' ==&lt;br /&gt;
&lt;br /&gt;
== '''Resources''' ==&lt;br /&gt;
DataSheet &amp;amp; Schematic: [https://www.sparkfun.com/products/8554 TSOP85338 Page on Sparkfun.com]&lt;br /&gt;
&lt;br /&gt;
Consumer IR: [http://en.wikipedia.org/wiki/Consumer_IR Wikipedia page on CIR]&lt;/div&gt;</summary>
		<author><name>Millerap</name></author>	</entry>

	</feed>