Generate hardware configuration headers from EAGLE for AVR GCC 

I have written an ULP to auto generate the pin numbering constants for my AVR projects from the schematic net names:

https://dl.dropboxusercontent.com/u/4295670/generate_header.ulp

How to use :
1. Name all your nets in your EAGLE schematic properly like this:


2. Run the generate_header.ulp and select the proper part.

3. Include the generated hwconfig.h file to your project.

4. You will have the follwoing structure for your each pins:

#define TX_EN_PORT PORTC
#define TX_EN_PINREG PINC
#define TX_EN_PIN 1
#define TX_EN_DDR DDRC
#define TX_EN C,1


5. Use the following macros with the defines:

// bit manipulation macros
// signals has to be defined in this way: #define LED C,1
// usage: sbi(PORT,LED1) or setting data direction: sbi(DDR,LED1)
// _BV(a) is a macro which returns the value corresponding to 2 to the power 'a'.
#define sbi_(what,x,y) what##x |= _BV(what##x##y) //set bit - using bitwise OR operator
#define cbi_(what,x,y) what##x &= ~(_BV(what##x##y)) //clear bit - using bitwise AND operator
#define tbi_(what,x,y) what##x ^= _BV(what##x##y) //toggle bit - using bitwise XOR operator

#define sbi(what,p) sbi_(what,p)
#define cbi(what,p) cbi_(what,p)
#define tbi(what,p) tbi_(what,p)

#define is_high_(x,y) ((PIN##x & _BV(PIN##x##y))) == _BV(PIN##x##y) //check if the y'th bit of register 'x' is high ... test if its AND with 1 is 1
#define is_high(p) is_high_(p)
#define is_low(p) !is_high_(p)

#define set_high_(x,y) (PORT##x |= _BV(PORT##x##y))
#define set_low_(x,y) (PORT##x &= ~_BV(PORT##x##y))

#define set_high(what) set_high_(what)
#define set_low(what) set_low_(what)

#define set_in_(x,y) DDR##x &= ~_BV(DD##x##y)
#define set_out_(x,y) DDR##x |= _BV(DD##x##y)
#define set_in(p) set_in_(p)
#define set_out(p) set_out_(p)

https://dl.dropboxusercontent.com/u/4295670/avr/global.h
[ hozzászólás ] ( 1 megtekintés ) [ 0 trackbackek ] permalink ( 3 / 1897 )
AVR libc _delay_ms() does not works after upgrading to Ubuntu Raring Ringtail 

After upgrading my system to kUbuntu 13.04 Raring Ringtail the delays in my avr-gcc compiled binaries had been gone.
After reading the #include <util/delay.h> documentation my eyes cached the __DELAY_BACKWARD_COMPATIBLE__ macro. After defining it the delays are working.

Workaround:

#define F_CPU 16000000UL
#define __DELAY_BACKWARD_COMPATIBLE__
#include <util/delay.h>
#include <avr/io.h>

int main(void
{
DDRB = 0xFF;
while (1) {
PORTB = ~PORTB;
_delay_ms(1000);
}
}



[ hozzászólás ] ( 3 megtekintés ) [ 0 trackbackek ] permalink ( 2.9 / 1958 )
Setting up Qt build enviroment for AVR32 development 

Currently I have a project which is based on the Atmel's NGW100 board.
It contains an 7' LCD display with touchscreen, an AC97 soundcard, a GPRS modem, and a PIC based board for controlling relay's, and so on.
The development time to make it working should be as sort as is possible. Read more...
[ hozzászólás ] ( 88 megtekintés ) [ 0 trackbackek ] permalink ( 2.9 / 2511 )

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

 
számláló