hbendali-blog
hbendali-blog
dataPayload
4 posts
by Hamza BENDALI BRAHAM
Don't wanna be here? Send us removal request.
hbendali-blog · 6 years ago
Text
KiCad EDA
Tumblr media
A Cross Platform and Open Source Electronics Design Automation Suite KiCad is a free software suite for electronic design automation (EDA). It facilitates the design of schematics for electronic circuits and their conversion to PCB designs. KiCad was originally developed by Jean-Pierre Charras. It features an integrated environment for schematic capture and PCB layout design. Tools exist within the package to create a bill of materials, artwork, Gerber files, and 3D views of the PCB and its components.
http://kicad-pcb.org/blog/
DZPCB is an youtube channel to learn all about pcb deogner in algeria.
https://www.youtube.com/channel/UCOVooodHocAKh3NVfOFlkAg/videos
0 notes
hbendali-blog · 6 years ago
Text
Makefile
Tumblr media
Les Makefiles sont des fichiers, généralement appelés makefile ou Makefile, utilisés par le programme make pour exécuter un ensemble d'actions, comme la compilation d'un projet, l'archivage de document, la mise à jour de site, etc. Cet article présentera le fonctionnement de makefile au travers de la compilation d'un petit projet en C.
Il existe une multitude d'utilitaires de Makefile fonctionnant sur différents systèmes (gmake, nmake, tmake, etc.). Les Makefiles n'étant malheureusement pas normalisés, certaines syntaxes ou fonctionnalités peuvent ne pas fonctionner sur certains utilitaires.
Le présent article se base sur l'utilitaire GNU make. Toutefois les notions abordées devraient être utilisables avec la majorité des utilitaires.
Un Makefile est un fichier constitué de plusieurs règles de la forme :
cible: dependance commandes
Chaque commande est précédée d'une tabulation.
Lors de l'utilisation d'un tel fichier via la commande make la première règle rencontrée, ou la règle dont le nom est spécifié, est évaluée. L'évaluation d'une règle se fait en plusieurs étapes :
Les dépendances sont analysées, si une dépendance est la cible d'une autre règle du Makefile, cette régle est à son tour évaluée.
Lorsque l'ensemble des dépendances est analysé et si la cible ne correspond pas à un fichier existant ou si un fichier dépendance est plus récent que la régle, les différentes commandes sont exécutées.
Les Makefiles nous offrent en plus une certaine souplesse en introduisant des directives, assez proches des directives de compilation du C, qui permettent d'exécuter conditionnellement une partie du Makefile en fonction de l'existence d'une variable, de sa valeur, etc.
Supposons, par exemple, que nous souhaitions compiler notre projet tantôt en mode debug, tantôt en mode release sans avoir à modifier plusieurs lignes du Makefile pour passer d'un mode à l'autre.
Il arrive parfois que l'on souhaite créer plusieurs Makefiles correspondant à des parties distinctes d'un projet (par exemple : client/serveur, bibliothèques de fonctions, sources réparties dans plusieurs répertoires, etc.).
Toutefois il est souhaitable que ces Makefiles soient appelés par un unique Makefile 'maître' et que les options soient identiques d'un Makefile à l'autre.
exemple d'un Makefile
CC=gcc CFLAGS=-W -Wall -ansi -pedantic LDFLAGS= EXEC=hello all: $(EXEC) hello: hello.o main.o $(CC) -o hello hello.o main.o $(LDFLAGS) hello.o: hello.c $(CC) -o hello.o -c hello.c $(CFLAGS) main.o: main.c hello.h $(CC) -o main.o -c main.c $(CFLAGS) clean: rm -rf *.o mrproper: clean rm -rf $(EXEC)
0 notes
hbendali-blog · 6 years ago
Text
USB programmer for Atmel AVR
Tumblr media
USBasp is a USB in-circuit programmer for Atmel AVR controllers. It simply consists of an ATMega88 or an ATMega8 and a couple of passive components.
The programmer uses a firmware-only USB driver, no special USB controller is needed.
Features:
Works under multiple platforms. Linux, Mac OS X and Windows are tested.
No special controllers or smd components are needed.
Programming speed is up to 5kBytes/sec.
SCK option to support targets with low clock speed (< 1,5MHz).
Planned: serial interface to target (e.g. for debugging).
LICENSEUSBasp is distributed under the terms and conditions of the GNU GPL version 2 (see "firmware/usbdrv/License.txt" for details).
USBasp is built with V-USB driver by OBJECTIVE DEVELOPMENT GmbH. See "firmware/usbdrv/" for further information.
LIMITATIONS
Hardware:
This package includes a circuit diagram. This circuit can only be used for programming 5V target systems. For other systems a level converter is needed.
Firmware:
The firmware dosn't support USB Suspend Mode. A bidirectional serial interface to slave exists in hardware but the firmware doesn't support it yet.
USE PRECOMPILED VERSION
Firmware:
Flash "bin/firmware/usbasp.atmega88.xxxx-xx-xx.hex" or "bin/firmware/usbasp.atmega8.xxxx-xx-xx.hex" to the used controller with a working programmer (e.g. with avrdude, uisp, ...).
Set jumper J2 to activate USBasp firmware update function.
You have to change the fuse bits for external crystal (see "make fuses").
# TARGET=atmega8    HFUSE=0xc9  LFUSE=0xef
# TARGET=atmega48   HFUSE=0xdd  LFUSE=0xff
# TARGET=atmega88   HFUSE=0xdd  LFUSE=0xff
Windows:
Start Windows and connect USBasp to the system. When Windows asks for a driver, choose "bin/win-driver". On Win2k and WinXP systems, Windows will warn that the driver is is not 'digitally signed'. Ignore this message and continue with the installation.
Now you can run avrdude. Examples:
1. Enter terminal mode with an AT90S2313 connected to the programmer:
  avrdude -c usbasp -p at90s2313 -t
2. Write main.hex to the flash of an ATmega8:
  avrdude -c usbasp -p atmega8 -U flash:w:main.hex
Setting jumpers:
J1 Power target
  Supply target with 5V (USB voltage). Be careful with this option, the circuit isn't protected against short circuit!
J2 Jumper for firmware upgrade (not self-upgradable)
  Set this jumper for flashing the ATMega(4)8 of USBasp with another working programmer.
J3 SCK option
  If the target clock is lower than 1,5 MHz, you have to set this jumper.
  Then SCK is scaled down from 375 kHz to about 8 kHz.
BUILDING AND INSTALLING FROM SOURCE CODE
Firmware:
To compile the firmware
install the GNU toolchain for AVR microcontrollers (avr-gcc, avr-libc),
change directory to firmware/
run "make main.hex"
flash "main.hex" to the ATMega(4)8. E.g. with uisp or avrdude (check the Makefile option "make flash"). To flash the firmware you have to set jumper J2 and connect USBasp to a working programmer.
You have to change the fuse bits for external crystal, (check the Makefile
option "make fuses").
Software (avrdude):
AVRDUDE supports USBasp since version 5.2.
install libusb: http://libusb.sourceforge.net/
get latest avrdude release:  http://download.savannah.gnu.org/releases/avrdude/
cd avrdude-X.X.X
configure to your environment: ./bootstrap (I had to comment out the two if-blocks which verify the installed versions of autoconf and automake) ./configure
compile and install it:
make
make install
Notes on Windows (Cygwin):
Download libusb-win32-device-bin-x.x.x.x.tar.gz from
http://libusb-win32.sourceforge.net/
and unpack it.
-> copy lib/gcc/libusb.a to lib-path
-> copy include/usb.h to include-path
cd avrdude
./configure LDFLAGS="-static" --enable-versioned-doc=no
make
Notes on Darwin/MacOS X:
after "./configure" I had to edit Makefile:
change "avrdude_CPPFLAGS" to "AM_CPPFLAGS" (why is this needed only on mac? bug in configure.ac?)
Notes on Linux:
To use USBasp as non-root, you have to define some device rules. See bin/linux-nonroot for an example.
FILES IN THE DISTRIBUTION
Readme.txt ............................. The file you are currently reading firmware ................................. Source code of the controller firmware firmware/usbdrv ...................... AVR USB driver by Objective Development firmware/usbdrv/License.txt ..... Public license for AVR USB driver and USBasp circuit ..................................... Circuit diagram in PDF and EAGLE format bin .......................................... Precompiled programs bin/win-driver ......................... Windows driver bin/firmware ........................... Precompiled firmware bin/linux-nonroot .................... Linux device rule file
MORE INFORMATIONFor more information on USBasp and it's components please visit the following URLs:
USBasp : http://www.fischl.de/usbasp/
Firmware-only V-USB driver : http://www.obdev.at/products/vusb/
libusb : http://libusb.sourceforge.net/
libusb-win32 : http://libusb-win32.sourceforge.net/
Software:
avrdude : http://www.nongnu.org/avrdude/
khazama : http://khazama.com/project/programmer/
eXtreme Burner : http://extremeelectronics.co.in/
Tumblr media
usbasp.2011-05-28.tar.gz
0 notes
hbendali-blog · 6 years ago
Text
C/C++ Macro & Bit Operations
Setting a bit Use the bitwise OR operator (|) to set a bit. number |= 1 << x; That will set bit x.
Clearing a bit Use the bitwise AND operator (&) to clear a bit. number &= ~(1 << x); That will clear bit x. You must invert the bit string with the bitwise NOT operator (~), then AND it.
Toggling a bit The XOR operator (^) can be used to toggle a bit. number ^= 1 << x; That will toggle bit x.
Checking a bit You didn’t ask for this but I might as well add it. To check a bit, AND it with the bit you want to check: bit = number & (1 << x); That will put the value of bit x into the variable bit.
#define bitset(byte,nbit) ((byte) |= (1<<(nbit))) #define bitclear(byte,nbit) ((byte) &= ~(1<<(nbit))) #define bitflip(byte,nbit) ((byte) ^= (1<<(nbit))) #define bitcheck(byte,nbit) ((byte) & (1<<(nbit)))
2 notes · View notes