my code :
#include <reg52.h> #include <stdio.h> #define uchar unsigned char void main() { uchar value; unsigned int address; uchar *data_buf; TMOD=0X20; // timer 1 mode 2 TH1=0xFD; // 9600 baud at 11.0592MHz TCON=0x40; // start baud rate clock SCON=0x52; // enable RX,TX address=0x01CF; value=0x66; *data_buf=value; printf("\nAddress %04xH Value : %02x",address,*data_buf); while (1); }
I have a question. In your example, where is data_buf pointing? Jon
Thanks Stefan Duncanson and Jon ward I can sole this problem as Stefan Duncanson say Thanks again
"I can sole this problem as Stefan Duncanson say" But your code still has a serious bug: As Jon said, you are using an uninitialised pointer!
Hello I wrote new program here,it correct? #include <reg52.h> #include <stdio.h> #define uchar unsigned char void main() { uchar value,data_in; unsigned int address; uchar *data_buf; TMOD=0X20; // timer 1 mode 2 TH1=0xFD; // 9600 baud at 11.0592MHz TCON=0x40; // start baud rate clock SCON=0x52; // enable RX,TX address=0x01CF; value=0x66; data_buf=&data_in *data_buf=value; printf("\nAddress %04xH Value : %02x",address,*data_buf); while (1); }
SO what is the purpose of the pointer? Why not write straight to data_in?
View all questions in Keil forum