Skip to content
Snippets Groups Projects
Commit e08faf3a authored by Sam Calisch's avatar Sam Calisch
Browse files

added raspberry pi zero with bcm2835

parent 8e3bbd74
No related branches found
No related tags found
No related merge requests found
RaspberryPiZeroW_bcm2835/bcm2835-02ma.png

7.42 KiB

RaspberryPiZeroW_bcm2835/bcm2835-06ma.png

8.37 KiB

RaspberryPiZeroW_bcm2835/bcm2835-16ma.png

14.1 KiB

<html>
<head>
<style>
pre code {
background-color: #eee;
border: 1px solid #999;
display: block;
padding: 20px;
}
</style>
</head>
<body>
<h1>RaspberryPi Zero W with BMC2835</h1>
<figure>
<img src='bcm2835-06ma.png'>
<figcaption>Ring oscillator with 6mA pad current.</figcaption>
</figure>
<p>This ring oscillator uses the <a href='http://www.airspayce.com/mikem/bcm2835/index.html'>BCM2835 library</a> from Mike McCauley. The code is available <a href='ring.c'>here</a>, or visible below.</p>
<pre>
<code>
//build:
// gcc -o ring ring.c -l bcm2835
//run:
// sudo ./ring
#include <bcm2835.h>
#include <stdio.h>
#define PIN_OUT RPI_GPIO_P1_11
#define PIN_IN RPI_GPIO_P1_15
int main(int argc, char **argv)
{
if (!bcm2835_init())
return 1;
//set changing pad current can change ringing characteristics on pulses
bcm2835_gpio_set_pad(BCM2835_PAD_GROUP_GPIO_0_27, BCM2835_PAD_DRIVE_6mA);
//this block is supposed to prevent kernel swapping
//I didn't get it to compile...
//struct sched_param sp;
//memset(&sp, 0, sizeof(sp));
//sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
//sched_setscheduler(0, SCHED_FIFO, &sp);
//mlockall(MCL_CURRENT | MCL_FUTURE);
bcm2835_gpio_fsel(PIN_OUT, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_fsel(PIN_IN , BCM2835_GPIO_FSEL_INPT);
//bcm2835_gpio_set_pud(PIN_IN, BCM2835_GPIO_PUD_UP);
while (1)
bcm2835_gpio_write(PIN_OUT, 1-bcm2835_gpio_lev(PIN_IN) );
bcm2835_close();
return 0;
}
</code>
</pre>
<p>We can change the pad current to improve the ringing of the pulses:</p>
<figure>
<img src='bcm2835-16ma.png'>
<img src='bcm2835-02ma.png'>
<figcaption>A) 16mA pad current, B) 2 mA pad current</figcaption>
</figure>
</body>
</html>
\ No newline at end of file
//build:
// gcc -o ring ring.c -l bcm2835
//run:
// sudo ./ring
#include <bcm2835.h>
#include <stdio.h>
#define PIN_OUT RPI_GPIO_P1_11
#define PIN_IN RPI_GPIO_P1_15
int main(int argc, char **argv)
{
if (!bcm2835_init())
return 1;
//set changing pad current can change ringing characteristics on pulses
bcm2835_gpio_set_pad(BCM2835_PAD_GROUP_GPIO_0_27, BCM2835_PAD_DRIVE_6mA);
//this block is supposed to prevent kernel swapping
//I didn't get it to compile...
//struct sched_param sp;
//memset(&sp, 0, sizeof(sp));
//sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
//sched_setscheduler(0, SCHED_FIFO, &sp);
//mlockall(MCL_CURRENT | MCL_FUTURE);
bcm2835_gpio_fsel(PIN_OUT, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_fsel(PIN_IN , BCM2835_GPIO_FSEL_INPT);
//bcm2835_gpio_set_pud(PIN_IN, BCM2835_GPIO_PUD_UP);
while (1)
bcm2835_gpio_write(PIN_OUT, 1-bcm2835_gpio_lev(PIN_IN) );
bcm2835_close();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment