Home
Data Sheet
Contents
1. Generate lst file rule golet 3 200 echo lst Se avr objdump bh S lt gt S 24 Page elementiu decho CC lt S CC c CFLAGS lt o SR PHONEY clean clean ii SE PO HELE SE Slet Melsele loge gt Program 48 bin bash Script to program 48pa device using AVRDUDE and a hex file LIE WEIL Wu 5 then echo Missing argument exit ile Eat if ends in hex use full argument otherwise add the hex ext 1 1 4 if Sext hex then kuse C pto o ml Een Si Ur asai r SL else Juse bin avcaude Sie ai Tor m48p Slehex Utlash w s lehex ip ab Save the above code in a file called program 48 and then run chmod 777 program 48 Use program_48 lt hex file gt to program the Atmega 48 device 9 Control Arduino Reset The Raspberry Pi GPIO 8 pin controls the Arduino reset pin when the jumpers are in place When starting the pin is LOW and thus the Arduino chip is held in reset To control the reset gpio 8 pin you can use the scripts shown below Don t forget to change the mode of the text file to executable format chmod 777 reset_off Depending on your path you may have to call the script starting with a lt dot gt lt slash gt reset off Alternative copy the scripts to usr bin sudo cp reset off usr bin If you want the Raspberry Pi to always execute the script at boot up you have to edit the etc rc local file Make sure that you have
2. TS4148RY D2 D20 B330A 13 F 2 C27 1nF 0603 RGA221M1VBK 10 3G J13 HEADER 6X1 R21 sek 0603 22uF 1210 20V P2pF 0603 B30nF 0603 Vin SS EN COMP R9 R10 1K5 0603 2K7 0603 GPIO10 BAS70 06 SOT23 Do Not Fit D23 L1 6u8H wurth Saturday September 28 2013 Sheet DBG 100nF 0603 D CONNECTOR 10X1 C2 C4 100nF 0603 TS4148R c3 4u7F_0805 J6 100nF 0603 MC DBG RESETn gt 1 5i 3 7 PC6 Reset n ADC5 SCL PC5 JL PDO RXD ADC4 SDA PC4 R PD1 TXD ADC3 PC3 PD2 INTO ADC2 PC2 E Bid IL sg PD3 INT1 OC2B ADC1 PC1 CONNECTOR E 12pF 0402 PD4 XCK TO ADCO PCO XTAL_IN PB6 XTAL1 SCK PB5 Ma S JMC SCK PB7 XTAL2 MISO OC2A PB4 tal ME M PD5 OCOB T1 MOSI OC2A PB3 lt mc Mosi PD6 OCOA AINO _ SS n OC1B PB2 PD7 AIN1 OC1A PB1 PBO CLKO ICP1 J8 ATmega328P XTAL IN 1 HEADER 1X1 Vi 16MHz 12pF 0402 J9 CONNECTOR 8X1 Size Document Number A4 lt Doc gt Date Saturday September 28 2013 Sheet 2 2 1 R40 330 0603 C10 100nF 0603 Gnd Vee C28 100nF 0603 DNF D25 SS sv DAT HOLD CR1025 BAT54C SOT23 C7 100nF 0603 cg Se jis u F_ D4 22K 060 d 100nF 0603 TS4148R HEADER 10X2 EX_DBG RESETn __ gt PC6 Reset n D Hr ADC5 SCL PC5 a PDO RXD SS ADC4 SDA PC4 PD1 TXD 2 ADC3 PC3 PD2 INTO ADC2 PC2 PD3 INT1 OC2B ADC1 PC1 pF 0402 DN PD4 XCK TO ADCO PCO PB6 XTAL1 SCK PB5 EX SCK XTAL1 18pF PB7 XTAL2 MISO OC2A PB4 3 EX_MISO X
3. Two RS232 buffer Yes Real Time Clock Yes Infra red interface Yes Table 1 Comparison GertDuino vs Arduino Uno 1 3 Vext As the board does not have a separate supply the Vext is not connected If you want it connected you have to add the following components J1 L4 or a short instead of L4 D20 or a short instead of D20 2 RS232 UART The Gerduino board has a RS232 level converter which will convert the signals form a UART to the RS232 standard voltages And invert them as per that same standard The RS232 signals come from J 12 Pin 3 is the receive Pin 2 is the transmit Pin 1 is the ground 4 Page elementi Connections can be made in many ways 2 1 Atmega 328 amp Pi UART Pi to RS232 buffers Atmega 328 to RS232 buffers Pi to Atmega 328 Pe SSeS SS SS SSS SS SSeS Se O E SS SS Se SS Se a po SS ee Se Se Raspberry Pi CG 4 Atmega 328 RS232 Raspberry Pi e Raspberry Pi gt 4 l Atmega 328 RS232 ji l l I l I l I l I l I l I l I l I l l I l Atmega 328 l RS232 I l l I l I l I l I l I I l buffers buffers buffers Atmega 48 2 2 Atmega 48 UART Atmega 48 to RS232 buffers Atmega 48 to Atmega 328 Atmega 48 to Pi pe a E SSS S gt 2
4. Pin Change Interrupt 2 9 PB1 OCIA Timer Counter1 Output Compare Match A Output PCINT1 Pin Change Interrupt 1 8 PBO ICP1 Timer Counter1 Input Capture Input CLKO Divided System Clock Output PCINTO Pin Change Interrupt 0 Name Functions ADC5 ADC Input Channel 5 A5 PC5 SCL 2 wire Serial Bus Clock Line PCINT13 Pin Change Interrupt 13 ADC4 ADC Input Channel 4 A4 PC4 SDA 2 wire Serial Bus Data Input Output Line PCINT12 Pin Change Interrupt 12 A3 PC3 ADC3 ADC Input Channel 3 PCINT11 Pin Change Interrupt 11 A2 PC2 ADC2 ADC Input Channel 2 PCINT10 Pin Change Interrupt 10 Al PCI ADC1 ADC Input Channel 1 PCINT9 Pin Change Interrupt 9 AO PCO ADCO ADC Input Channel 0 PCINT8 Pin Change Interrupt 8 IliPage elementiu Name Functions PD7 AINI Analog Comparator Negative Input PCINT23 Pin Change Interrupt 23 6 PD6 AINO Analog Comparator Positive Input OCOA Timer CounterO Output Compare Match A Output PCINT22 Pin Change Interrupt 22 5 PD5 T1 Timer Counter 1 External Counter Input OCOB Timer CounterO Output Compare Match B Output PCINT21 Pin Change Interrupt 21 4 PD4 XCK USART External Clock Input Output TO Timer Counter 0 External Counter Input PCINT20 Pin Change Interrupt 20 3 PD3 INT1 External Interrupt 1 Input OC2B Timer Counter2 Output Compare Match B Output PCINT19 Pin Change Interrupt 19 2 PD2 INTO External Interrupt 0 Inp
5. To program this device from the Raspberry Pi you have to place the following 4 jumpers Then run the script Program 328as described in section 8 1 Atmega 328 To program the 328 using a JTAG I CE you need to use the squid cable and make the following connections LED The first debug tool any programmer grabs for 6lPage elementi At the left there are the GND white and 5V Purple connections At the top row right are the Reset green Mosi Red Clk Black and Miso Grey The equivalent JTAG names for these are nSRST TDI TCK TDO 3 3 Using running the Atmega 328 When the device has been programmed it will run that program independent of the Raspberry Pi In fact you can remove the board from the Raspberry Pi and use it standalone When developing programs you may leave the jumpers in place as the programme will tri state its pins and set the reset pin high when it has finished This is NOT the case if the PI is reset or not powered Especially the reset jumper needs to be removed otherwise the Raspberry Pi GPIO pin 8 which is default low will the keep the 328 device in reset or you can run the reset off script You should also remove the jumpers if you want to use any of the following pins B3 B4 B5 C6 4 Atmega 48 4 1 Features This device is intended to be used as Real Time Clock RTC and or as IRDA front end However it is also freely programmable by the user and thus can be used for any
6. battery holder but between the supply and the battery holder you have to place a current Ampere meter Optionally you can connect a scope on one of the I O pins of the Atmege48 to see if the program is running You should NOT connect anything to one of the output which loads an I O pin as that will cause extra current consumption This is a block diagram of the setup Gertduino 3V Atmega48pa d GND I eh T A ed ed D EE E 8 8 And this is how it looks in real life The meter shows a current consumption of 1 3uAmp The meter is shown enlarged in the lower left hand corner of the picture 9 Page elementi If possible limit the current from your power source to a few milli amps managed to blow a fuse of my meter performing the measurements because I accidentally shorted the supply when placing the probe on the battery holder 4 7 Atmega 48 LED trick If you are debugging an LEDS is often the first tool you reach for But the Atmega 48 does not have any LEDs However the Atmega 328 does There are two ways in which you can use these LEDs e The safest way is to remove the 328 from its socket e The second way is to erase the 328 so that all its pins are inputs You can then use the connectors to feed a signal to an LED Simplest way is to use a female male strap between connector J 10 and e g pins 2 3 or 6 of J14 5 Connectors The board con
7. can put avoid safe mode 1 in the config txt file and the pi will boot normally Why is there no battery supplied O The GertDuino has a battery holder but there is no battery in there Why do I have to buy my own A These batteries are lithium batteries Those are classified as Dangerous Goods and require special paper work warning labels and other precautions when shipped And that is for shipping within the UK International shipping becomes a nightmare So we decided to leave it off 16 1Page elementi 7 How to start Before you can program the devices you need to have a cross compiler A cross compiler is a compiler which runs on one type of processor but generates code for a different type In this case the compiler runs on the Raspberry Pi ARM11 device but makes code for the Atmel devices 7 1 On the Raspberry Pi When programming the Atmel devices on the Raspberry Pi you have two choices e Use the Arduino GUI e Use the GCC Atmel compiler For both you need to have a cross compiler for the Atmega devices Easiest is to install the Arduino package sudo apt get install arduino avrdude You need to use a program called avrdude to program the devices BUT you need a special version of avrdude which can program the devices using the GPIO of the Raspberry Pi Thanks for Gordon Henderson projects drogon net who has provided these Standard Debian Squeeze cd tmp wget http project downloads drogon ne
8. the 48 when the device has been programmed it will run that program independent of the Raspberry Pi In fact you can remove the board from the Raspberry Pi and use it standalone When developing programs you may leave the jumpers in place as the programme will tri state its pins and set the reset pin high when it has finished This is NOT the case if the PI is reset or not powered Especially the reset jumper needs to be removed otherwise the Raspberry Pi GPIO pin 8 which is default low will the keep the 48 device in reset or you can run the reset off script You should also remove the jumpers if you want to use any of the following pins B3 B4 B5 C6 4 4 Real Time Clock The Atmege 48 device has a 32768Hz crystal connected to operate as a Real Time Clock RTC Example code for this can be found under section 8 2 Atmega 48 The Crystal is a high guality type and under normal conditions a deviation is less than 1 sec 3 days The other part of the RTC is that the Atmega 48 has a 3V battery It will switch to that battery when the 5V power is removed As the Atmega 48 is a fully programmed microcontroller it can be set up to perform other operations or hold other data when the main power of the BCM2835 is removed If you have programmed the Atmege 48 correctly it uses 1uA when powered down 4 5 Infra red receiver remote control receiver The BCM2835 does not have a native IRDA interface The protocol can be implemented using a standard
9. the full path in there Thus if you have installed the script in usr bin you have to add the following line to etc rc local Jusr bin reset off 25 Page elementi reset off The following script will release the Arduino reset and thus make that the Arduino chip runs It only works if the GertDuino is plugged in to the Raspberry Pi and the reset jumper is in place usr bin sudo bash Set GPIO pin 8 high releasing Arduino reset sudo echo 8 gt sys class gpio export sudo echo out gt sys class gpio gpio8 direction sudo echo 1 gt sys class gpio gpio8 value sudo echo 8 gt sys class gpio unexport reset on The following script will assert the Arduino reset and thus make that the Arduino chip stops is held in reset It only works if the GertDuino is plugged in to the Raspberry Pi and the reset jumper is in place usr bin sudo bash Set GPIO pin 8 low activating Arduino reset sudo echo 8 gt sys class gpio export sudo echo out gt sys class gpio gpio8 direction sudo echo 0 gt sys class gpio gpio8 value sudo echo 8 gt sys class gpio unexport 10 Appendix A GertDuino Schematic 26lIPage GPIO0 2 GPIO1 3 GPIO17 GPIO22 MOSI GPIO10 MISO GPIO9 SCLK GPIO11 CONNECTOR 13X2Z 3V3 RASP R8 GPIO14 Tx GPIO15 Rx GPIO18 GPIO23 GPIO24 GPIO25 2K7 0603 GPIO0 2 SDA 2N7002 5V R13 C23 100nF 0603 2K7 0603 GPIO1 3 2N7002 FB 1206 C25 1nF 0603
10. top to bottom are the pins from right to left Beware that Pin 8 of J9 is normally connected directly to the input voltage which has been removed and thus is NC here 13 lPage elementi 5 3 Atmega 48 All unused pin of the Atmega 48 are brought out to a 20 pin connector 1 1 5V 0 0 13 PB5 SCK 12 PB4 MISO 11 PB3 MOSI 10 PB2 SS ADC1 PC1 A1 OO ADC2 PC2 A2 O QO 9 PB1 PCINT1 ADC3 PC3 A3 O O 8 PBO CLKO RXD PDO 0 OO 7 PD7 AIN1 TXD PD1 1 OO 6 PD6 AINO TO PD4 4 O O 5 PD5 T1 Ground OQ O Ground The supply 5V VBAT which goes to the Atmega 48 also goes to the connector pin 3 Any equipment connected to that pin will also draw current from the battery if the 5V is switched off The supply comes through a Schottky diode so the actual voltage is lower 4 5 Volts Also the current consumption should be limited 100mA The following pins of the ATmega 48 are dedicated connected Pin Hard wired to Function PD2 5V Supply Detect absence of 5V supply for RTC PD3 IRDA output Receive IRDA signal PC5 SCL 12C connection with the Pi PC4 SDA 12C connection with the Pi PB7 XTAL1 32768Hz Tuning crystal PB6 XTAL2 32768Hz Tuning crystal PC6 Program reset Reset when programming The Atmege 48 does not have a dedicated reset pin as that would interfere with it
11. upload the program it runs fine but when I halt the Raspberry Pi or when I start the Raspberry Pi my program does not work A GPIO 8 controls the Reset of the Arduino This pins must be high but for your program to run The simplest solution is to remove the programming jumpers Alternative is to program the GPIO 8 pin high using the reset_off script The avrdude with the c gpio option does this for you so normally after programming the reset has been removed I have a different compiler O I use the AVR compiler on my PC How do I program the Atmega on the Raspberry Pi A I have only experience with the GCC version AVR 5 1 and higher After compilation you find a hex file in the debug directory You have to transfer that file somehow to the Raspberry Pi and use the programmer script Program 328 as described in 8 lAtmega 328 to program the device s on the GertDuino If you have the script already installed use program 328 lt hex file gt The Raspberry Pi boots different it has big text and not the normal prompt Q When I plug the GertDuino on the Raspberry Pi it boots different It has big text and not the normal prompt A Pin 5 of the GPIO connector is used to indicate safe boot mode If that pin is low when booting the Raspberry Pi boots in safe mode Pin 5 is also connected to the Atmge 48 It is one of the I2C pins Thus if your 48 is driving a LOW on that pin the Pi always boots in safe mode To prevent this you
12. Eeer ere ee ee Sr S r 1 Raspberry Pi gt Atmega 328 RS232 Atmega OK 1 kf o 1 Raspberry Pi gt i lt q ls i I Atmega 328 ier RS232 1 Atmega ane fas 1 1 buffers Filc20 0231 Steck 5lPage elementi 3 Atmega 328 3 1 Features This device is compatible with the Arduino Uno In contrast to the 328 on the GERTBOARD this device runs of 5V has the 16MHz oscillator and has connectors which are 10096 Arduino Uno compatible It also contains the reset switch This board also has the following components which you will not find on the Uno e 2 User push buttons e 6LEDs LEDs One LED is connected to PB5 aka Port 13 aka SCK This is compatible with the UNO The GertDuino has a five more LEDs The total list of LEDs is PB5 Port 13 PB1 Port 9 PB2 Port 10 PD3 Port 3 PD5 Port 5 PD6 Port 6 The LEDs are not directly connected but are buffered and thus do not give any significant load on the signal pins User buttons The two user buttons are connected to pins PC2 and PC3 They will only function correctly if the pins have an internal or external pull up The button are connected through a 1K Ohm resistor so they will not cause a short if a pin is set as output and the button is pressed 3 2 Program the Atmega 328
13. GPIO pin but that puts a very heavy burden on the CPU To support IRDA the Atmega 48 has a TSSOP4038 IRD device connected to pin D3 This device supports the most common IRDA protocol 38KHz IR signal Unfortunately we could not run the IRDA interface from the battery as it uses too much current 450 uA Thus you need the 5V present for it to operate The IRDA can also be used if the GertDuino is used stand alone to control the connected logic using a remote control The colours used here are the same as on MY squid cable but I can t guarantee all squid cables are the same 8lPage elementi Note that 95 of all TV Video CD remote controls use the 38KHz infra red signal but the coding varies greatly from type to type 4 6 Battery Drain If a battery is present and the power of the Raspberry Pi is switched of the Atmega 48 will still remain powered by the Battery It will also keep running Unless the battery is removed or the Atmega 48 is programmed to go into a special ultra low power condition the battery will be drained in a short time Even if you think the device is in ultra low power mode it can still consume power if it has to drive outputs high Measurements have also show that if a UART connection exists between the Atmega 48 to the Raspberry Pi even if it is not used that increases the lower power current from 1pA to about 100A To measure the current consumption you have to use a 3V supply and connect it to the
14. TAL2 8pF PD5 OCOB T1 MOSI OC2A PB3 EXB2 lt JEK MOSI PD6 OCOA AINO SS_n OC1B PB2 EXB1 XTAL SMD C12 PD7 AIN1 a OC1A PB1 PBO CLKO ICP1 a SW 10pF 0402 Size Document Number A4 lt Doc gt Date Saturday September 28 2013 Sheet 3 2 1 C13 74HC14D power connection 100nF 0603 LEDO __ gt i Vi M74HC14TTR Vi R39 M74HC14TTR 22K_0603 U3C 1KX4 TC164 Vi u8 M74HC14TTR U3E 10 L M74HC14TTR U3D Vi M74HC14TTR 1KX4_TC164 U3F 012 Vi M74HC14TTR itle Gertduino I O Size Document Number A4 lt Doc gt Date Saturday September 28 2013 Sheet 4 2 1
15. Vinex Jp raen usr bin avrdude c gpio p m328p 1 Uflash w 1 else usr bin avrdude c gpio p m328p 1 hex Uflash w 1l hex EE Save the above code in a file called program 328 and then run chmod 777 program 328 Use Jprogram 328 lt hex file gt to program the Atmega device Initial clock setup avrdude qq c gpio p atmega328p U lock w 0x3F m U efuse w 0x07 m D ruses w Ossi 7 Sim U tte swe 0de em You normally run the above command when you get a brand new device It programs the Atmega328 to use the external 16MHz Crystal 8 2 Atmega 48 This section shows an example program for the Atmega48 You will find that the makefile and the programming files are very similar to the 328 example low power c source code Example code which uses the 32767KHz Crystal to implement a 1 second event handler Atmega Low power operation example Using a 32768 Khz crystal on timer 2 and full power down mode to implement a 1 second event handler his code is written for the GCC compiler Example for the GertDuino Atmega 48PA device This program will NOT run on the 328 his code is freeware 22 Page elementiu 44 include lt avr interrupt h gt include lt avr sleep h gt volatile unsigned long count seconds main set PBO as output DDRB OxFE Set up 32 KHz oscillator TIMSK2 0x00 No interrupts ASSR 0x20 IL asyne run trom zal EENI2 Os fi elear Cow
16. elementi GertDuino Board Exclusively From A elementi GERTBOARD User Manual By G J van Loo Version 1 3 Dated Gr Nov 2013 elementi ContentS eeen 2 1 Wo dee e In de EE 3 ECK Ke LL WAA S 3 US E e une EE A 103 MON a a ia aaa ii ae e a a a i a a ere ner ee 4 2 RS232 UART renneri eene 4 2 1 Atmega 328 amp Pi UART nnen enenneneenennenvenveneenennenveneenennenvenvenennenvenveneenennenvenvenennen 5 22 EE gn EA WEE 5 3 Atmega 328 E A 6 E Oe 6 3 2 Program the Atmega 328 annen nenseneenennenveneeneenennenvenveneenensenvenvenennenseneenvenen 6 3 3 Using running the Atmega 228 7 4 Atmega 48 inmeten nae i a y A ee ia ais 7 Awl LD EEn 7 4 2 Program the Atmega A9 7 4 3 Using running the Atmega A8 8 4 4 Real TIME COG aisiais dai iki di k iii dia i ia a i i i i i i i i i i ned 8 4 5 Infra red receiver remote control receiver mimi imma 8 4 6 Battery Nia 9 4 7 Atmega 48 LED UU ua 10 e dE e Te TC 10 5 1 Alternate functions 77722 10 5 2 e CET E 12 e E A e E EE 14 SA Ras Pl iia 15 6 Frequently Asked Questions FAQS nennen eneenseeneeneenerenenneeneenvenn 16 1 How TO Start Aa 17 Jel Om th Raspbernry Pli venster Kiauras as i a i tan i a aa tee 17 he Ona PO nennen ON ee 17 8 Example programs eee 19 8 1 Atmegas328 ia 19 8 2 Atmega 48 AA 22 9 Control Arduino Reset nnen eneenennenvenveneenenvenvenvenennenvenve
17. fine F CPU 16000000 Some macros that make the code more readabl define output low port pin port ke 1 lt lt pin define output high port pin port 1 lt lt pin define set input portdir pin portdir amp 1 lt lt pin define set output portdir pin portdir 1 lt lt pin Owo Ames EDO PBS EDA PB ED2 PB2 EDS PDS ED4 BDS EDS PD6 void delay ms unsigned intms uint16 t delay count F_CPU 17500 WOLECLILS wale le je sp while ms 0 roe Sp a celle count ale g lay_ms lay 1 done cls unsigned char oldb ol for d 0 d lt DELAY d4 delay_ms 1 if PINC amp 0b00001 PORTB PORTD PORTB PORTD delay ms 1 PORTB elementi 19 Page elementi PORT edel df else if PINC amp 0b00000100 0 1 if button pressed if button pressed delay int main void Af me lop 24 Ser all LED connections LA SW DDRB 0b00100110 DDRD 0b01101000 PORTB 0x00 PORTD 0x00 Il Ser lowuccon pore to Amour DDRC 0b00000000 Akon up om CA amp C33 PORTH DEET 100 while 1 convoluted but simple walk the leds tput_high PORTB 5 delay tp ONM PORTED tput_high PORTB 1 delay tp low PORTB 1 tput_high PORTB 2 delay EIS lop PORE tput high PORT delay tput_low PORT tput_high PORT delay tput_low PORT tpu
18. later version y m m This is distributed in the hope that it will be useful F but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE see the m y m GNU General Public License for more details You should have received a copy of the GNU General P long with this If not see lt http www gnu org 1 HEHEHE EHH HH HHH HH HH EE FE FE EEE HEH EH AA E E E EE EEE RGET low_power U atmega48p EWQ 1000000 Debug EBUG gstabs C flags GE AVE GGC CFLAGS S DEBUG 03 Wall std gnu99 mmcu MCU DF CPU FREWQ S INCLUDE CFLAGS S DEBUG 02 mcall prologues Wall std gnu99 mmcu MCU DF CPU FREWQ S INCLUDE LD awir Gee PODE LAGS LSL Uve prame Dimi se ic LDFLAGS mmcu S MCU DEBUG LIBLOC LDFLAGS2 LIBS ldross lm SRC S TARGET c OBJ SORO es ll all S TARGET hex TARGET bes TARGET elf echo hex S lt avr objcopy J text J data O ihex TARGET elf TARGET hex S TARGET elf S OBJ echo Link lt S LD o S S OBJ S LDFLAGS S LIBS avr size TARGET elf
19. mesic TCCR2B 0x05 IN Prescales 5 128 fi Warte Por all Vousy bics LO be Glass That happens on the first timer overflow which can take 8 seconds if you have a max pre scaler while ASSR amp 0x07 TIMSK2 0x01 overflow IRO enable count seconds 0 clear seconds counter Seip set the Global Interrupt Enable Bit while 1 SMCR 0x7 Go into lowest power sleep mod asm sleep asm nop Interrupt woke us up If we get here the interrupt routine has already been called Toggle LED on port BO using LS timer bit PORTB count seconds amp 0x01 main Timer 2 overflow if we set timer2 up correctly this routine is called every second M ISR TIMER2 OVF vect count seconds all we do here is count seconds elapsed 23 Page elementi Makefile Makefile Make the GertDuino m48p firmware Copyright c 2013 Gordon Henderson lt projects drogon net gt EE TE a HH HH eH EH TE FE HE FE FE HE HEH HE HE EEE EE HE FE FE HE EE HEE EE HE HEE EERE EH This file is part of gertduino m328 FSoftware to run on the Atmega328p processor on the Gerduino board FCan be used for the Atmega328p processor on the GERTBOARD as well This is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any
20. neenennenvenvenennenn 265 10 Appendix A GertDuino SchematiC nnn eeneeneenennenvenveneenenvenveneenenn 26 21Page elementiu 1 Introduction The GertDuino is a Raspberry Pi add on board which offers the same functionality as an Arduino Uno but with some extra added features 1 1 Identify The picture below lets you identify the various functions on the board e RS232 level converter can be used by o Raspberry Pi o or Atmega 328 o or Atmega 48 e Atmega 328 Arduino Uno compatible with o Arduino Uno compatible connectors o Reset button o 2 user push buttons o 6 LEDs e Atmega 48 with o 1 O connector with 20 pins o High precision RTC crystal o Battery backup power supply o IRDA interface PCB Overview weer ee ewe me e z LJ 2 2 e e A e e e e e e e IRDA receiver See 12 JJ ee ee ee 4 Battery for RTC 4 ee 2 md _ Reset button ENE lh A A SG GW Ge A e s e e ee ae e e ees eebe ee AAA GLEDS MB Morel O i RTCX tal 4 J Ld M ennn 2user buttons Renn Picture 1 GertDuino Functions 3lIPage elementi 1 2 Comparison There are some differences between a normal Arduino Uno and the GertDuino Function Arduino Uno GertDuino USB Slave interface Reset button Yes Yes Power supply 7 12V 250mMA lt 5V Raspberry Pi gt 3V3 supply 50mA 150mA LED s One Not buffered Six Buffered User pushbuttons
21. of the GNU General P long with this If not see lt http www gnu org 1 HEHEHE HH HH HH HH HH HH HH HE FE FE E EE EH EH EH EH E E HE RGET blink U atmega328p EWQ 16000000 Debug EBUG gstabs avr gee S DEBUG O3 Wall std gnu99 mmcu MCU DF CPU FREWQ S INCLUD S DEBUG O2 mcall prologues Wall std gnu99 mmcu MCU DF CPU FREWQ S INCLUDE LD GEI EDELAGS2 MP 0515 9 24651535 DEE en e GE le LDFLAGS mmcu MCU S DEBUG LIBLOC LDFLAGS2 leleoss Le S TARGET c SUE ss E TARGET hex ARGET hex S TARGET elf echo hex lt avr objcopy j text j data O ihex TARGET elt TARG S TARGET elf S OBJ echo Link lt S LD o OBJ S LDFLAGS LIBS avr size TARGET elt Generate lst file rule ES 3 506 echo lst Se Cavr objdump a S lt gt S 21lIPage elementi echo CC lt S CC c CFLAGS S lt o SR Eg clean wim i HO SO Sex Ist Malketileloalk Program 328 bin bash script to program 328p device using AVRDUDE and a hex file if Si WW then echo Missing argument exit 1 Bat t if ends in hex use full argument otherwise add the hex ext S 1 S 1 4 dae Jr Sexi
22. other application giving the user the power of not one but TWO Atmega devices to play with Note The I2C interface of the Atmega 48 is connected permanently to the Raspberry Pi 2C interface lt GOIO0 1 on rev1 GPIO 2 3 on rev2 gt Also beware that if you make programming errors with the Atmege 328 the device can easily be replaced This is not the case with the Atmega 48 It is therefore strongly recommended that you are extra careful and do not damage any of the I O ports Spare connections The following I O pins of the Atmega 48 are not used and are brought out to a connector BO B1 B2 B3 B4 B5 C0 C1 C2 C3 D0 D1 D4 D5 D6 D7 Beware that B3 B4 and B5 are also used for programming the device 4 2 Program the Atmega 48 To program the Atmega 48 from the Raspberry Pi you have to place the following 4 jumpers The programming is the same as the 328 but replace 328p with 48pa The colours used here are the same as on MY squid cable but I can t guarantee all squid cables are the same 7 Page elementi To program the 48 using a JTAG ICE you need to use the squid cable and make the following connections At the left there are the GND white and 5V Purple connections At the bottom row right are the Reset green Mosi Red Clk Black and Miso Grey The equivalent JTAG names for these are nSRST TDI TCK TDO 4 3 Using running the Atmega 48 What was written about the 328 also is valid for
23. s function as real time clock A reset can be obtained by pulling pin 4 of J13 low 14 Page elementi 5 4 Raspberry Pi All connections between the board and the Raspberry Pi are protected against 5V signals The 1 C bus has FET level switches All the other signals use resistive dividers The following connections of the Raspberry Pi are used 5V 3V3 I C level converters only GPIO0 2 I C SDA GPI01 3 I C SCL The following connections of the Raspberry Pi are used if the programming jumpers or UART jumpers are placed GPIO14 GPIO15 GPIO8 GPIO9 GPIO10 GPI011 UART Tx UART Rx Reset MISO MOSI SCLK EE En e ae 15 Page elementiu 6 Frequently Asked Questions FAQs Some questions you may ask and the answers avrdude AVR device not responding Q When I try to program the device get an error avrdude AVR device not responding A The most likely cause is that you have forgotten to place the four programming jumpers See section 3 2 Program the Atmega 328 Why is my program slow Q When I run the program it is very slow Where expect a delay of 1second it takes much longer A Straight from the factory the CPU runs from the internal 8MHz clock and that is divided by 8 Thus the processor runs at 1 MHz To switch to the full speed using the external 16MHz oscillator run the avrdude command as described in 8 1Atmega 328under Initial clock setup Why does my program not run Q When I
24. t gertboard avrdude 5 10 4 armel deb sudodpkg i avrdude 5 10 4 armel deb sudochmod 4755 usr bin avrdude Debian Raspbian cd tmp wget http project downloads drogon net gertboard avrdude 5 10 4 armhf deb sudodpkg i avrdude 5 10 4 armhf deb sudochmod 4755 usr bin avrdude You can now compile programs for the Atmega devices and upload the program into the chip on the GertDuino Example source code Makefile and how to upload the program can all be found in section 8 Example programs If you want to use the Arduino development environment you have to adapt it See projects drogon net raspberry pi gertboard arduino ide installation isp how to do that 7 2 Ona PC Atmel have a free C compiler You can get information about the latest version here http www atmel com tools ATMELSTUDI O aspx You can compile on the PC but you need to transfer the final hex file to the Raspberry Pi before you can program the Atmega devices 17 Page elementiu Alternative is that you buy a JTAG ICE box and use that to program and the devices but that is a lot more expensive It does have the advantage that you can use it for debugging as well Step through the program set breakpoints inspect variables etc 18 Page 8 Example programs 8 1 Atmega 328 blink c source code Created 23 09 2013 21 04 02 L Aukos God van Loo Simple example program to walk the LEDs SS include lt avr io h gt define DELAY 250 de
25. t_high PORT delay tput_low PORT tput_high PORT delay tp low PORT tput_high PORT delay EIS low PORE tp t high PORT delay Erop Low EC 2 Ewe Pen PORIE 1 delay cue Lom E ORTE 1 forever main 20lIPage elementi Makefile Makefile F Make the GertDuino m328p firmware f Copyright c 2013 Gordon Henderson lt projects drogon net gt EE TE FE HE TE FE HE HE FE FE HE TE FE E FE FE HE TE FE FE HE FE FE HE FE FE HE FE FE HE FE FE HE FE FE E FE FE FE HE FE FE E TE FE HE TE FE FE HE FE FE HE FE FE E TE F HE E E E E E H E This file is part of gertduino m328 FSoftware to run on the Atmega328p processor on the Gerduino board Can be used for the Atmega328p processor on the GERTBOARD as well F This is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published the Free Software Foundation either version 3 of the License or at your option any later version mi y ij This is distributed in the hope that it will be useful F but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the mi mi y GNU General Public License for more details You should have received a copy
26. tains a number of connectors You will find that in the document the connectors of the Atmega devices have two ways of numbering There are the single numbers 0 13 and A1 A3 These are the numbers used in many Arduino example programs Alongside those use the official pin names PBO PB7 PDO PD7 PCO PC3 The latter are easier to use if you have to work with the AVR datasheet 5 1 Alternate functions The Atmega 328 and the Atemege 48 have exactly the same pins with the same functionality The devices only differ in the size of their various memories The following is a table of the pins and all the functions they can carry These where copied from the AVR datasheet For details of the functions you should read that datasheet 101Page elementiu Name Functions PB7 XTAL2 Chip Clock Oscillator pin 2 TOSC2 Timer Oscillator pin 2 PCINT7 Pin Change Interrupt 7 PB6 XTAL1 Chip Clock Oscillator pin 1 or External clock input TOSCI Timer Oscillator pin 1 PCINT6 Pin Change Interrupt 6 13 PB5 SCK SPI Bus Master clock Input PCINT5 Pin Change Interrupt 5 12 PB4 MISO SPI Bus Master Input Slave Output PCINT4 Pin Change Interrupt 4 11 PB3 MOSI SPI Bus Master Output Slave Input OC2A Timer Counter2 Output Compare Match A Output PCINT3 Pin Change Interrupt 3 10 PB2 SS SPI Bus Master Slave select OC1B Timer Counter1 Output Compare Match B Output PCINT2
27. ut PCINT18 Pin Change Interrupt 18 1 PD1 TXD USART Output Pin PCINT17 Pin Change Interrupt 17 0 PDO RXD USART Input Pin PCINT16 Pin Change Interrupt 16 5 2 Atmega 328 The Atmega 328 pins are brought to connectors compatible with the Arduino Uno j14 J7 C_I i i r Pin Signal Pin Signal No No 10 A5 PC5 SCL 8 7 PD7 AIN1 9 A4 PC4 SDA 7 6 PD6 Al N0 LED6 8 AREF 6 5 PD5 T1 LED5 7 Ground 5 4 PD4 TO 6 13 PB5 SCK LEDO 4 3 PD3 INT1 LED4 5 12 PB4 MISO 3 2 PD2 INTO 4 11 PB3 MOSI 2 1 PD1 TXD 3 10 PB2 SS LED2 1 0 PDO RXD 2 9 PB1 PCINT1 LED1 12 Page elementiu 1 8 PBO CLKO Pin 1 is on the right hand side so these tables top to bottom are the pins from left to right J9 J6 E a J GE Eo Pin Signal Pin Signal No No 8 NC 6 A5 PC5 SCL 7 Ground 5 A4 PC4 SDA 6 Ground 4 A3 PC3 ADC3 BUT1 5 5V 3 A2 PC2 ADC2 BUTO 4 3V3 2 A1 PC1 ADC1 3 Reset Active low 1 AO PCO ADCO 2 5V 1 NC Pin 1 is on the left hand side so these tables
Download Pdf Manuals
Related Search
Related Contents
BENDIX BW2916 User's Manual Carretera de Sangroniz 34 BS-150 - reed instruments Kensington K39762AM mobile device charger (pont de terenez). - VINCI Construction France Ficha Técnica AD2030-CC Copyright © All rights reserved.
Failed to retrieve file