-
-
Neuer Benutzer
Öfters hier
Vielen Dank!!! Ich versuche etwas tun aber jetzt ich habe eine andere probleme mit ein header...
Entschuldigen Sie mir fuer die Englisch:
In order to implement 2 SW UART in my AVR mega16(3,6864) I have searched and finally found out a solution.
http://<br />
<a href="http://www.s...cts</a> <br />
This SW UART needs only a Timer to work and succeed 19200baud rate in 8MHz. Because of my need of 2 SW UART(I know the solution of picking up another avr)I have doubled the numbers of the original names in order to have another one,but this was designed for the avr-gcc and I work with CodeVision. It had given me some errors but I have fixed them. The only one I couldn`t fix and that`s why I am needing your help,if you know of course,is about the headers.
My headers:
#include <mega16.h>
#include <string.h>
#include <stdio.h>
SW headers:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/pgmspace.h>
#include "softuart.h"
My error comes in the last line of my code,in while.
It said that a `)` is missing.
Code:
void softuart_puts( const unsigned char *s )
{
while ( *s ) softuart_putchar( *s++ );
}
void softuart_puts_p( const unsigned char *prg_s )
{
unsigned char c;
while ( ( c = pgm_read_byte( prg_s++ ) ) ) softuart_putchar(c);
}
I found out that pgm_read_byte is a specific expression for the GCC compilerhttp://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html#g73084a8bbde259ffae72980 354b3f027. Can I make it work with some way in CodeVision??
RE:
Change the pointer declaration.
The flash storage modifier can be used in various ways (depending on its relative location within the variable declaration or argument list) to specify what memory space a pointer lives in or points to. Look in your CodeVision help files for details.
Once CodeVision knows the storage type of the memory being pointed-to, the pointer can be dereferenced directly; the pgm_read_byte() macro can be omitted.
Kostas:
void putsf(char flash*str) is ok??
void softuart_putsf( unsigned char *prg_s )
{
unsigned char c;
while ( c = prg_s++ ) softuart_putchar(c);
}
It didn`t gave me an error...but it is correct??
RE:
Are you aware of the fundamental reason there are two different versions of the function? One accepts pointers to strings that reside in Flash (softuart_puts_p), and the other accepts pointers to strings that reside in SRAM (softuart_puts).
The argument list
Code:
void softuart_puts_P(unsigned char flash *prg_s)
...
seems to be correct.
Kostas:
@If morrison thanks!!! I have forgotten flash. In my book Embedded C Programming and the Atmel AVR says :
" The putsf function transmit the contact string str using the standart putchar function, or an alternate putchar function if one has been defined. The string must be null-terminated. A newline character is appended to the end of the string when it is transmitted.Finally the string must be located in FLASH. (see puts for string located in RAM.) The putchar function defaults to transmitting characters using the UART."
And in the SW UART.zip in one file it s said:
"
// Write a NULL-terminated string from RAM to the serial port
void softuart_puts(const unsigned char *s);
// Write a NULL-terminated string from program-space (flash) to the serial port
// i.e. softuart_puts_p(PSTR("test"))
void softuart_puts_p( const unsigned char *prg_s );
// Helper-Macro - "automaticly" inserts PSTR
#define softuart_puts_P(s___) softuart_puts_p(PSTR(s___))"
I don`t know if in CodeVision exists puts_P(My book doesn`t have any reference)!! If it exists why had given me pgm_read_byte false(only in gcc??propably yes!!)?? With the string.h or stdio.h we accept this expression(putsf).
Do you know what is PSTR???
I have tried to do something( with puts or putsf ) but when I omit the pgm_read_byte gives me lots of warnings(10-15) unreferenced function!!!
What can I do????
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
-
Foren-Regeln
Lesezeichen