The DarK EvIL
Newbie level 3

Hi everybody!!
I'm using the PIC 18F4550 to establish communication between a GSM module and a PC.
The USB communication works perfectly, however I can't get the Serial communication to work.
I'm using a 8MHz cristal. I can't send data through the Tx pin but I can't get any data back.
I noticed that an interruption occurs when a data is received but the data is not correct.
here is my code:
I also tried the Soft_UART fucntion but it doesn't work either.
Please can someone help me??
Thx.
I'm using the PIC 18F4550 to establish communication between a GSM module and a PC.
The USB communication works perfectly, however I can't get the Serial communication to work.
I'm using a 8MHz cristal. I can't send data through the Tx pin but I can't get any data back.
I noticed that an interruption occurs when a data is received but the data is not correct.
here is my code:
Code:
char uart_rd ='0';
unsigned char Read_buffer[64];
unsigned char Write_buffer[64];
void interrupt()
{
HID_InterruptProc(); // Keep alive
TMR0L = 100; // Reload TMR0L
INTCON.TMR0IF = 0; // Re-enable TMR0 interrupts
portb =~ portb;
}
void main() {
// Disable all interrupts
// Disable GIE, PEIE, TMR0IE, INT0IE,RBIE
INTCON=0;
INTCON2=0xF5;
INTCON3=0xC0;
// Disable Priority Levels on interrupts
RCON.IPEN=0;
PIE1=0;
PIE2=0;
PIR1=0;
// Timer 0
T0CON = 0x47; // Prescaler = 256
TMR0L = 100; // Timer count is 256-156 = 100
INTCON.TMR0IE = 1; // Enable T0IE
T0CON.TMR0ON = 1; // Turn Timer 0 ON
INTCON = 0xE0; // Enable interrupts
ADCON1 = 0xFF; // Set PORTB to digital I/O
TRISB = 0; // Set PORTB to outputs
PORTB = 0; // PORTB all 0s to start with
// Enable USB port
Hid_Enable(&Read_buffer, &Write_buffer);
Delay_ms(1000);
Delay_ms(1000);
strcpy(Write_buffer,"hi\r\n");
delay_ms(100);
UART_Init(9600);
Delay_ms(100);
while(1)
{
if(UART_Data_ready())
{
uart_rd = UART1_Read();
UART1_Write(uart_rd);
}
}
}
I also tried the Soft_UART fucntion but it doesn't work either.
Please can someone help me??
Thx.