suit WELCOME TO MY logo WEEK 7

RETURN TO HOMEPAGE

Embedded Programming

Hi pals?..this is the embedded programming week and its sort of a recap of last week Electronics Design where I redrew the Hello world board adding an led and a button which was a success...only this time I`m being required to program the board to do something in as many programming languages as possible.. I took up the challenge with great zest since I was trying to catch up in electronics quite fast...
Let me start by pointing out a few key areas Prof. Neil touched upon..
  • various architectures i.e Harvard, von Neumann RISC, CISC microprocessor, microcontroller FPGA, CPLD ALA
  • Several peripherals such as: A/D ,comparator, D/A, timer/counter/PWM,USART, USB,,

  • programmer families we introduced:8051 PIC MSP AVR ARM STM32 PSoC, xCORE, Propeller

  • Various AVR processors were explained in detail:

    ATtiny10 ATtiny45V ATtiny44A ATmega328P ATmega16U2 ATxmega16E5 ATxmega16C4
    Wait a minute::

    Ok this are the design as designed and modified in Eagle CAD:
    led_________led...
    This is me working on the board accompanied with the final working board..
    led_________led...
    Not so fast pals.. here is the code I used in making the board work...The first programming language I worked with was C and used AVR to generate makefile...I used an off-the shelf programmer not FabIsp..
    .include "tn44def.inc"
    .equ ledpin = PB2; led pin
    .equ led_port = PORTB; led port
    .equ led_dir = DDRB; led direction
    .equ delay_value=255 ; delay time in cycles

    .def temp = R17; temporary storage
    .def temp1 = R18; temporary storage
    .def temp2 = R19; temporary storage
    .def temp3 = R20; temporary storage

    .cseg
    .org 0; boot
    rjmp reset



    delay:
    mov r16,temp
    outer_loop:; duration ~

    ldi r26, 0; set r26 to zero
    ldi r27, 0; set r27 to zero
    delay_loop:;~262143*65535+3= 17179541508 cycles
    adiw r26, 1; add 1 to r26 and r27
    ldi r28, 0; set r28 to zero
    ldi r29, 0; set r29 to zero
    delay_loop1:;~4*65535+3= 262143 cycles
    adiw r28, 1; add 1 to r28 and r29; 2 cycles
    brne delay_loop1; if no overflow loop; 1 or 2 cycles
    brne delay_loop; if no overflow loop

    dec r16; dcrement R16
    brne outer_loop; if no overflow loop
    ret


    ;
    ; main program
    ;
    reset:
    ; designate fuse 0x7E for 20 MHz resonator
    ;
    ; designate clock divider to /1
    ;
    ldi temp, (1 << CLKPCE)
    ldi temp1, (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0)
    ;ldi temp1, (1 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);/256
    out CLKPR, temp
    out CLKPR, temp1
    ;
    ldi temp, high(RAMEND)
    out SPH, temp
    ldi temp, low(RAMEND)
    out SPL, temp
    ;
    ; init led pin as input
    ;
    ;sbi = Set Bit in I/O Register
    ;
    sbi led_port,ledpin
    sbi led_dir,ledpin
    ;
    ; start main loop
    ;
    loop:
    sbi led_port,ledpin; led ON
    ldi temp,100;delay 1 sec
    rcall delai; delay
    cbi led_port,ledpin; led OFF
    ldi temp,50;delay 0.5sec
    rcall delai; delay
    rjmp loop; relative jump to loop

    You can also check my first code I used but was quite an issue so i decided to move on with the above code...I'm just saying you could give it a try maybe it'll work....

    #include
    #include
    #define bit_get(p,m) ((p) & (m))
    #define bit_set(p,m) ((p) |= (m))
    #define bit_clear(p,m) ((p) &= ~(m))
    #define BIT(x) (0x01 << (x))
    int main()
    {
    //SETUP
    //Button is on PA3
    //LED is PA7
    bit_clear(DDRA,BIT(2)); //clear DDRA bit 7 makes PA3 (pin 6) an input to monitor my pushbutton - I don’t need pull-up resistor
    bit_set(DDRB,BIT(5)); //Set DDRA bit 2 makes PA7 (pin 5) an output to control my LED
    //LOOP
    while (1)
    {
    if(bit_get(PINA,BIT(2)))//button is not
    {
    bit_clear(PORTB,BIT(5));//LED is off
    }
    else // button is pushed
    {
    bit_set(PORTB,BIT(5));//LED is on

    }
    }


    Ok this is the rest of the material we covered in class:
    packages :
    DIP SOT SOIC TSSOP TQFP LQFP MLF, CSP, BGA

    clocks : RC (10%, 1% calibrated) ceramic (0.5%) quartz (50 ppm)

    in-system development :

    ISP (header, pads, clip) bootloader JTAG, debugWire, PDI ICE

    programmers :

    ISP AVRISP FabISP avrdude JTAG, debugWIRE, PDI Atmel-ICE

    assembly language : hex file instruction set, opcodes mnemonics, directives, expressions avr-as gavrasm C GCC AVR Libc

    modules types math avr-libc, binutils-avr, gcc-avr WinAVR CrossPack Atmel Studio

    host communication : RS232 bit timing VT100/ANSI/ISO/ECMA terminal Kermit Minicom term.py USB software

    hardware FTDI cable libFTDI echo hello-world hello.ftdi.44.cad board components traces interior

    programming hello.ftdi.44.echo.c hello.ftdi.44.echo.c.make hello.ftdi.44.echo.interrupt.c hello.ftdi.44.echo.interrupt.c.make

    hello.ftdi.44.echo.asm hello.ftdi.44.echo.asm.make

    IDE :

    Atmel Studio Eclipse AVR Firefly Scratch Modkit

    boards :
    Arduino board + C libraries + IDE + bootloader Fabkit Fabio hello.arduino.328P.cad board components traces

    interior Blink.pde boards.txt programming hello.arduino.328P.blink.c hello.arduino.328P.blink.make programming

    ATtiny PSoC Maple Tessel BeagleBone PandaBoard Rasberry Pi

    Interpreters :

    Python BASIC FORTH AVRSH JavaScript

    debugging :

    "printf" Atmel Studio gdb, ddd, Insight

    STM32:

    processor STM32F3 data sheet toolchain gcc-arm-none-eabi sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded

    OpenOCD http://sourceforge.net/projects/openocd/files/latest/download?source=files QStlink2 sudo add-apt-repository ppa:mobyfab/qstlink2

    stlink git clone https://github.com/texane/stlink.git programmer ST-Link V2 software ST library STMCube board

    STM32F3Discovery software blink.zip programming Nucleo

    Well thats it for this week, I`ll keep on practicig and updating however till next time..cheers.