Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Suart pic2550

Status
Not open for further replies.

be80be

Well-Known Member
Could some one have look at this I zipped the whole MPLAB-X project
Im just getting a ?P output not the text I should be getting.
 

Attachments

  • SUART.zip
    326.9 KB · Views: 165
Yes I got it set 115200 Changed it to 9600 and got the same thing "?P"
The first one I use MMC and then changed chip setting to 18f2550
I found this which I got it to work but there is a bug in it I can send data 0 to 255
or text but not both
uart.h
C:
char UART_Init(const long int baudrate)
{
    unsigned int x;
    x = (_XTAL_FREQ - baudrate*64)/(baudrate*64);
    if(x>255)
    {
        x = (_XTAL_FREQ - baudrate*16)/(baudrate*16);
        BRGH = 1;
    }
    if(x<256)
    {
     SPBRG = x;
     SYNC = 0;
     SPEN = 1;
          TRISB7 = 1;
          TRISB6 = 0;
          CREN = 1;
          TXEN = 1;
     return 1;
    }
    return 0;
}

char UART_TX_Empty()
{
  return TRMT;
}

char UART_Data_Ready()
{
   return RCIF;
}
char UART_Read()
{

  while(!RCIF);
  return RCREG;
}

void UART_Read_Text(char *Output, unsigned int length)
{
    unsigned int i;
    for(int i=0;i<length;i++)
        Output[i] = UART_Read();
}

void UART_Write(char data)
{
  while(!TRMT);
  TXREG = data;
}

void UART_Write_Text(char *text)
{
  int i;
  for(i=0;text[i]!='\0';i++)
     UART_Write(text[i]);
}
main.c
C:
 do
  {
    UART_Write(100);
    __delay_ms(500);
     UART_Write_Text("I'm alive");
    __delay_ms(500); 
  }while(1);
}
[code]
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top