heise online · c't · iX · Technology Review · Telepolis · mobil · Security · Netze · heise open · heise resale · Autos · c't-TV · Jobs · Kiosk
Zum Inhalt
c't

c't Projekte - c't-Bot und c't-Sim - Mailinglisten

c't-Bot und c't-Sim


[Voriger (Datum)] [Nächster (Datum)] [Voriger (Thread)] [Nächster (Thread)]
[Nach Datum][Nach Thread]

[ct-bot] Problem mit Pointern

Absender: Carsten Giesen
Datum: Sa, 01.04.2006 19:57:46


Hallo Zusammen,

Ich bräuchte mal bitte Hilfe. Da ich den Code von AVR übernommen habe, tue
ich mich schwer den Fehler zu finden.

Hier rufe ich eine Routine auf:

	state = Get_byte(data_pack[i].data_ptr++,j);

Und Zwar diese:

unsigned char Get_byte(unsigned char *rx_ptr,char last_byte)
{
	Wait_TWI_int();
//Wait for TWI interrupt flag set

	/*When receiving the last byte from the slave it will be sent a NACK
to 
	make the slave stop transmitting, all bits before the last will get 
	a ACK*/
	if(last_byte)
//Not the last byte
		//Clear int flag and enable acknowledge to receive data.
		TWCR = ((1<<TWINT)+(1<<TWEA)+(1<<TWEN));
	else
//Last byte
		/*Clear int flag to and do not enable acknowledge to tell
the slave 
		to stop transmitting*/
		TWCR = ((1<<TWINT)+(1<<TWEN)); 			
	Wait_TWI_int();
//Wait for TWI interrupt flag set

	*rx_ptr = TWDR;
//Save received byte

	/*If ACK has been transmitted or this was the last byte and NACK has
been
	sent -> return SUCCESS, else return TWSR*/	
 	if(((TWSR == MRX_DATA_NACK)&&(last_byte == 0))||(TWSR ==
MRX_DATA_ACK))
		return SUCCESS;	  
	return TWSR;
}

Das Problem ist, das der Werte den ich lese, nicht in
"data_pack[i].data_ptr++" ankommt.

Was ist da falsch?

DANKE

Carsten


Copyright © 2007 Heise Zeitschriften Verlag Kritik, Anregungen bitte an c't-WWW Datenschutzhinweis   Impressum