Errors found by a total beginner of Raspberry Pi

Because I was a total beginner, I have referred from multiple sources, and I found things written on books are not always correct.

It could be fortune that I was a total beginner of electronics because I had questions. If I was not a beginner, I wouldn’t have found these errors. For people who are in trouble, I would like to share what I found.

Error 1

Nikkei Linux March 2013

I thank this book very much because this book introduced me RasPi, but there are some errors. First of all, it explains GPIO.

If you use BCM2708, you have to configure GPIO to input mode first, and then configure again to output mode .

You don’t need to configure twice. You can configure GPIO to output mode immediately.

This error might come from the source code posted on elinux.org.

INP_GPIO(g); // must use INP_GPIO before we can use OUT_GPIOOUT_GPIO(g);

And Raspberry Pi uses BCM2835, not BCM2708. I don’t know if this leads the error.

Cambridge, the inventor of RasPi, opens the following example code and I verified this code worked.

if (direction == OUTPUT)
*(gpio_map+offset) = (*(gpio_map+offset) & ~(7<<shift)) |="" (1<<shift);<="" pre="">

C library for Broadcom BCM 2835 as used in Raspberry Pi has the same code.

v = (v & ~mask) | (value & mask);

Error 2

The Cambridge code shown in Error 1 has an error. This is the code to configure GPIO to pull up and down.

short_wait();
*(gpio_map+clk_offset) = 1 << shift;
short_wait();
*(gpio_map+PULLUPDN_OFFSET) &= ~3;
*(gpio_map+clk_offset) = 0;

This code should be:

*(gpio_map+PULLUPDN_OFFSET) &= ~3;
*(gpio_map+clk_offset) = 1 << shift;
short_wait();
*(gpio_map+clk_offset) = 0;
short_wait();

November 9, 2014 Update:

Error 2 was not an error. The definition of “clock” of BCM2835 is different from the one of SC1602, which I didn’t know.

Error 3

There is an error on the circuit of Raspberry Pi and SC1602 in Nikkei Linux March 2013.

Circuit with an error

Nikkei201303-1

Correct circuit

Nikkei201303-2

I found a site that examined a circuit using SC1602.

液晶表示モジュールを4ビットモードで使ったときの空きピン処理

If you only output from RasPi to SC1602, “Circuit with an error” works. But if unexpected errors happen in SC1602 and DBs turn accidentally from input to output, electricity flows from SC1602 to RasPi, which makes a circuit without resistance and causes overcurrent.

Actually, RasPi and SC1602 don’t break because both have internal resistors, and RasPi has a function to detect overcurrent and turns itself off. (This is my individual view. I short pins often by accident and RasPi turns off every time.)

This error doesn’t seem to settle. I bought an infrared remote controller kit at Akizuki, and I found it has the same error.

Akizuki Infrared Kit

DB0-3 and R/W are connected to GND.

The site also explains how to add voltage after sending data and waiting the new data. What you need to do is simple. When you finish sending command to your SC1602, configure GPIOs other than E (DBs, R/W, RS) to input mode, voltage high and pull up until you send next command. I was amazed by the result.

GPIO and Current

It reduced electricity more than half! The result is incredible. And I really thought that not knowing is a big loss, and to realize we don’t know is very hard.

Error 4

This is a circuit of Raspberry Pi and a switch written in Nikkei Linux March 2013.

Nikkei201303-3

You should use a resistor between GPIO4 and SW.

Nikkei201303-4

Cambridge’s site explains very well. If you set GPIO to output mode by mistake, the circuit has overcurrent.

If you are interested in this post, check all posts about Raspberry Pi and Electronics DIY. For example, I posted these articles.

  • A total beginner started to learn electronics with Raspberry Pi
    A cigarette-box-size computer Raspberry Pi “bridged” between my knowledge of computer science and electronics. More precisely, RasPi made me one of zombies that crowd around circuit boards and connectors. LOL
  • Electronics with Raspberry Pi Vol. 2
    I couldn’t understand what current, resistance and voltage meant, but having spent money (aka investment 😉 ), I’m getting to understand what they mean.
  • Tools I bought besides Raspberry Pi
    4 months have passed since I got a RasPi and started to learn electronics. As I study, I needed to buy many things including books, electronic parts and tools. Today I show you what tools I’ve bought besides RasPi.

This post is also available in: Japanese

Leave a Reply

Your comment will be sent to me via e-mail so that I don't miss it. Required fields are marked *