I forgot to mention, that the Linux program must be executed as root. Otherwise it will not work, because it needs low level access to the serial port.
And the program must be compiled with optimization turned on.
The correct preprocessor command for GCC under Linux is "__linux__" - with two underscores and in small letters.
All commands in the instruction set are stated as ASCII characters. The return values and the parameters are in hex.
If someone got the circuit to work with Windows XP, please inform me. ;)
Showing posts with label gcc. Show all posts
Showing posts with label gcc. Show all posts
Tuesday, December 28, 2010
UART toy - additional comments...
Labels:
atmega,
avr,
gcc,
linux,
microcontroller,
programming,
rs232,
testboard,
uart,
windows
Monday, December 27, 2010
UART toy - part 3
And another part (not the last one) of my UART series.
Here is a piece of code for the PC to establish a connection to the RS232 testboard and to communicate with it..
http://sites.google.com/site/species0x2118/testboard.zip
It is just an example how to interface with the board and not a complete library. The example application sets the outputs, reads in the inputs, reads the analog input and calculates the voltage on that pin. Everything with hardware handshake.
But you need the right cable for the handshake. Otherwise change the "true" in the uartSend commands to "false" and delete the handshake activation.
The software is tested under DOS with TurboC and under Ubuntu Linux with GCC. The source compiles with Open Watcom too - but the Watcom binary is not tested under DOS yet.
I changed the compiler preprocessor macros for the recognition of operating systems and compilers several times - but did not test every combination with every operatin system and every compiler. Perhaps you need to figure out the correct setup for your system (or just delete the stuff you do not need).
It took me several hours to figure out, that linux needs an activated FIFO control register. Otherwise the data transmission will fail in 99% of the cases.
Here is a piece of code for the PC to establish a connection to the RS232 testboard and to communicate with it..
http://sites.google.com/site/species0x2118/testboard.zip
It is just an example how to interface with the board and not a complete library. The example application sets the outputs, reads in the inputs, reads the analog input and calculates the voltage on that pin. Everything with hardware handshake.
But you need the right cable for the handshake. Otherwise change the "true" in the uartSend commands to "false" and delete the handshake activation.
The software is tested under DOS with TurboC and under Ubuntu Linux with GCC. The source compiles with Open Watcom too - but the Watcom binary is not tested under DOS yet.
I changed the compiler preprocessor macros for the recognition of operating systems and compilers several times - but did not test every combination with every operatin system and every compiler. Perhaps you need to figure out the correct setup for your system (or just delete the stuff you do not need).
It took me several hours to figure out, that linux needs an activated FIFO control register. Otherwise the data transmission will fail in 99% of the cases.
Tuesday, February 23, 2010
Clock - some hints and thoughts
I have reprogrammed the clock-thermometer the first time after soldering it to the breadboard.
In the circuit diagram you can throw away jmp3 and jmp4 and replace them with a common jumper on the mass of D2 and R7.
Because my wall power supply not only outputs 9 V DC but also ~13 V AC, i decided to power the circuit with rechargeable batteries (4*1,2 V).
I thought it could help to change the following line:
Where ADC_BITS is defined as 10 and VREF as 1100 (mV).
Indeed the code size shrinked from 3132 bytes to 3060 bytes, but the temperature was calculated wrong. The thermometer displayed a negative temperature, although my room was warm.
When i changed the code to:
The filesize was 3132 bytes again.
As you can see: the AVR GCC port isn't as stupid as you (or me) think. ;)
Happy soldering!
In the circuit diagram you can throw away jmp3 and jmp4 and replace them with a common jumper on the mass of D2 and R7.
Because my wall power supply not only outputs 9 V DC but also ~13 V AC, i decided to power the circuit with rechargeable batteries (4*1,2 V).
I thought it could help to change the following line:
degree = (degree * VREF) >> ADC_BITS;to:
degree = ((degree * 1024) + (degree * 64) + (degree * 8) + (degree * 4)) >> ADC_BITS;
Where ADC_BITS is defined as 10 and VREF as 1100 (mV).
Indeed the code size shrinked from 3132 bytes to 3060 bytes, but the temperature was calculated wrong. The thermometer displayed a negative temperature, although my room was warm.
When i changed the code to:
degree = ((degree * 1024L) + (degree * 64L) + (degree * 8L) + (degree * 4L)) >> ADC_BITS;
The filesize was 3132 bytes again.
As you can see: the AVR GCC port isn't as stupid as you (or me) think. ;)
Happy soldering!
Subscribe to:
Posts (Atom)