Having fun with a touchscreen and asm

Subforo dedicado exclusivamente a la electrónica y a la robótica, incluyendo la programación orientada a la robótica en sí.
Robots con patas, ruedas, orugas, humanoides, insectoides, ... ¡Sed todos bienvenidos!

Moderador: nake

Avatar de Usuario
nake
管理者 (Admin)
Mensajes: 1992
Registrado: Vie Jun 04, 2010 4:10 pm
Ubicación: (sin(3t), 0, 0, t+10)
Contactar:

Having fun with a touchscreen and asm

Mensajepor nake » Mié Ene 25, 2017 10:05 am

(This post is only in english / este post está solo en inglés)

This is just a few memories from my on-going project. I started it long time ago, looking at the timestamp in the pictures, around summer 2015. It is very poorly written because it is written for me, and so that if someone gets interested, we can start a conversation about it. Or, you know, you could just go to the pictures to see what I did.
My main idea is to create my own phone, without OS or anything, just stuff that I 100% created myself instead.


Some time ago I bought an OLIMEX MOD-LCD4.3'' to play a bit with.
The funny part was that all the tools and programmers are non-free (and quite expensive) and it was the first time I was working with real hardware (not toys like arduino and such), and I wanted to do everything on my own.
So I took gcc, cross-compiled it, researched a lot, and was able to create a sample project that was able to blink a led in the back. That might seem like something simple, but oooh boy, it is not.

CAM00007.jpg


What did I accomplish? So basically I got my tools to program, compile code and upload it, access some of the hardware available, timers, LCD, touchscreen, external RAM and buttons. I created a few internal libraries to work with, like image loading (animated gif playing), colored console output, mouse movement using the touchscreen and timers. Everything done in C and assembly, without any extra library except to access the CPU control registers, that I took from an open-source project and ported line by line it to work for me from another compiler. It was a really fun project and I even brought everything from Spain to Japan in one of my last trips so that I can keep working on it. And I tell you, I am going to continue working on this.

CAM00020.jpg



So how did everything go? Is it hard?

Yes. It is.

When programming in a normal PC you get for granted a lot of stuff. You see all those beautiful printf functions? They don't exist if there is not an OS behind your program. See that screen you can write to, or the console? Ha! Have fun writing into it without the OS (actually, in a normal PC is quite easy, just find the correct hardware address and write there taking into account a few things). It is not that much the thing that you have to setup the access to the hardware, it's the fact that the driver that talks to the hardware doesn't even exist. Even choosing that a global variable has an initial value is non-trivial if you don't have anything: you need to create a small utility to do that fills the memory before calling the main() function. And you need to setup the different signal tables and setup the hardware.

CAM00005.jpg


In my specific project I found out reading the LCD specs that the required buffer has to be provided by you, so you go to the CPU specs and see that you don't have that much memory, but, lucky you, the hardware is also opensource and the guys that designed this thing added a big enough RAM memory for you to use. Reading the specs of the CPU, memory and wiring, you decide the settings that you have to load to the CPU so that it can access the RAM memory, then, reading the specs of the LCD you setup the CPU so that it can hardware-accelerate the access to the LCD using the provided RAM. Everything would be perfect if the guys writing the specs did their job, tho.

Once you have that, you have to setup your environment. I was using vim to write my source code, but then, you have to upload it using the JTAG interface so you have to install OpenOCD. For me, the default package was not enough so I had to compile from source and install it, setup the scripts so that the JTAG debugger can connect to the system, and the board and CPU are the ones I was using. It was fun, but hard.
Then you need to create you linker scripts to tell the linker where to put each part of the code (keep in mind that the RAM is non continuous because there are hardware registers in between, and the external RAM memory is in a specific address, and it has the LCD buffer on it, and that there are tables for functions used as callbacks for the CPU if something important happens). And that stuff has very very low documentation (I hope to write my own once I feel comfortable enough to be teaching this).

CAM00003.jpg


I will continue this soon.
Mi clave pública de correo electrónico: http://www.nakerium.com/nakerium.gpg (Si no sabes lo que es lee este artículo)
Click aquí para ver mi email.


Programo aplicaciones a la carta (con soporte de por vida, para ingeniería o informática) y doy asesoramiento en seguridad informática. Si quieres más información mándame un email o un mensaje privado.
Avatar de Usuario
nake
管理者 (Admin)
Mensajes: 1992
Registrado: Vie Jun 04, 2010 4:10 pm
Ubicación: (sin(3t), 0, 0, t+10)
Contactar:

Re: Having fun with a touchscreen and asm

Mensajepor nake » Mié Ene 25, 2017 10:10 am

Oh, I have a video of the touchscreen in action! (Sorry that loading speeds are bad)

http://www.nakerium.com/files/CAM00008.mp4

And another pic:
CAM00006.jpg
Mi clave pública de correo electrónico: http://www.nakerium.com/nakerium.gpg (Si no sabes lo que es lee este artículo)
Click aquí para ver mi email.


Programo aplicaciones a la carta (con soporte de por vida, para ingeniería o informática) y doy asesoramiento en seguridad informática. Si quieres más información mándame un email o un mensaje privado.

Volver a “Robótica y electrónica”

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado