View RSS Feed

alexan_e

  1. How to program your mbed board using Keil uVision instead of the online compiler

    -
    Create a new project in Uvision and then open the project properties

    write fromelf --bin -o @L.bin !L in the "run user program after build" command.
    This command generates the bin file from the elf file


    Create a MBED_Flash.bat with the following content and place it in the project folder
    Code:
    :Batch file for copying to MBed
    :argument 1: .bin output file
    :argument
    ...
    Tags: mbed Add / Edit Tags
    Categories
    Uncategorized
  2. Long integer to string function

    This is a custom function to convert a number to the ASCII representation

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    
    /*****************************************************************************
    ** Function name:   ULongToStr
    **
    ** Descriptions:    converts an unsigned long to ASCII characters and stores the result to a char array
    **                  
    ** parameters:      unsigned long value : number to be converted
    **                  char *str : pointer to the first char of the array
    **                  char leading_zero
    ...

    Updated 1st November 2012 at 11:14 by alexan_e (added function comment)

    Categories
    AVR
  3. 8/16 bit value reverting function (11000000 to 00000011)

    Fast value reverting function for 8-bit char and 16-bit integer, it uses a lookup table for each nibble (4-bits).

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    
    /*****************************************************************************
    ** Function name:   reverse_byte    
    **
    ** Descriptions:    reverts the bits of a byte b0->b7, b1->b6, b2->b5 etc
    **                  
    ** parameters:      unsigned char input_byte : the values that will be inverted 
    ** Returned value:  unsigned char : the reverted
    ...

    Updated 1st November 2012 at 11:21 by alexan_e (added function comment)

    Categories
    AVR
  4. PWM in ATMEGA

    The atmega has a few different PWM modes, the frequency and duty ratio depend on the mode and values used, this is a description of the way to calculate them.

    In fast PWM top=ICR1, the output PWM frequency=timer clock/(ICR1+1) and the duty=OCR1A(B)/ICR1
    In fast PWM top=0h00ff, the output PWM frequency=timer clock/256 and the duty=OCR1A(B)/256
    In fast PWM top=0h01ff, the output PWM frequency=timer clock/512 and the duty=OCR1A(B)/512
    In fast PWM top=0h03ff, the ...
    Categories
    AVR
  5. Write/read the internal EEPROM in AVR using avrgcc (winAVR)

    The following macro can be used to simplify the process of using the internal AVR EEPROM

    Code:
    #include <avr/eeprom.h>
    // defines for eeprom access	
    #define read_eeprom_byte(address) eeprom_read_byte ((const uint8_t*)address)
    #define write_eeprom_byte(address,value) eeprom_write_byte ((uint8_t*)address,(uint8_t)value)
    #define read_eeprom_word(address) eeprom_read_word ((const uint16_t*)address)
    #define write_eeprom_word(address,value) eeprom_write_word
    ...

    Updated 3rd August 2014 at 18:24 by alexan_e (Added float)

    Categories
    AVR
Page 1 of 2 1 2 LastLast