Click here to Skip to main content
14,384,144 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi

I have written the code for serially send data transmission between PC-hyper-terminal and PIC16F877A. When I am using MP LAB IDE Hitech C compiler its showing the error like pointer is required and any of you please check the code and register description is correct or not

What I have tried:

  #include<pic.h>
  #include<string.h>


void pic_init(void)
{
	TRISC7=1;
	TRISC6=0;
}

void uart_init(void)
{
	TXSTA=0x20;
	RCSTA=0x90;
	SPBRG=15;
}

void tx(unsigned char byte)
{
int i;
TXREG=byte;
while(!TXIF);
for(i=0;i<400;i++);
}

void string_uart(char *q)
{
	while(*q)
	{
	*(*q++);
}
}
unsigned char rx()
{
	while(!RCIF);
	return RCREG;
}



void main()
{

	//char *q;
	pic_init();
	uart_init();
	tx('N');
	rx();
	string_uart("test program");
}
Posted
Updated 15-Apr-19 10:45am
v3
Rate this:
Please Sign up or sign in to vote.

Solution 1

Quote:
void string_uart(char *q)
{
while(*q)
{
*(*q++);
}

Did you actually mean
void string_uart(char *q)
{
  while(*q)
  {
    tx((unsigned char) *q);
    ++q;
  }
}

?
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

void string_uart(char *q)
{
  while(*q)
  {
    tx(*q++);
  }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100