Dear all,
I'm working on a project that includes receiving data from a GPS receiver, pre-process it on a PIC and store the result on SD-Card.
For this project I'm using PICDEM FS USB Demo Board, PICTail Daughter board for the mass storage. I'm trying to do a software serial communication between the receiver & Board which has PIC18F4550 because when using the hardware USART, the RX pin conflicts with SD0 (i.e in & out at the same time). I don't get correct output. Everyone have told me that the code is correct but still couldn't find what's causing the strange output
Here is my code & what I got as output.
the Config Bits:
1. clock src from 96MHz PPL/2
2. OSC1/OSC2 src:/1, 96MHz PPL src:/2
3. divide by 5 (20MHz input)
4. Oscillator: HS:HS+PPL, USB-HS
5. Baud rate=9600
I'm using MPLAB C18.
At the begining PORTD value is 8 and then all the LEDs connected to that port are OFF. I never got the letter G on the hyper terminal and whenever I type a number OR letter on the hyper terminal I got someting else(which is not correct because whatever value recieved must be sent back) (e.g when typing 1 I got = and sometimes o) and never got 'Hello".
Waitnig for your replies.
Regards,
I'm working on a project that includes receiving data from a GPS receiver, pre-process it on a PIC and store the result on SD-Card.
For this project I'm using PICDEM FS USB Demo Board, PICTail Daughter board for the mass storage. I'm trying to do a software serial communication between the receiver & Board which has PIC18F4550 because when using the hardware USART, the RX pin conflicts with SD0 (i.e in & out at the same time). I don't get correct output. Everyone have told me that the code is correct but still couldn't find what's causing the strange output
Here is my code & what I got as output.
Code:
#include <p18f4550.h>
#include <sw_uart.h>
#include <delays.h>
#define config WDT = OFF
#define CLK 48000000
#define BAUD 9600
/* FUNCTION PROTOTYPES */
void DelayTXBitUART(void);
void DelayRXHalfBitUART(void);
void DelayRXBitUART(void);
/* END FUNCTION PROTOTYPES */
//Main
void main (void)
{
TRISD=0;
PORTD=0;
TRISBbits.TRISB4=0; //TX (out)
TRISBbits.TRISB5=1; //Rx (in)
PORTBbits.RB4=0;
ADCON0 = 0x00;
ADCON1 = 0x0F;
OpenUART();
WriteUART('G');
PORTD=8;
while(1)
{
PORTD=ReadUART();
Delay1TCY();
WriteUART(PORTD);
putsUART("Hello");
}
PORTD=2;
}
//End
//Delay Functions
//===============
void DelayTXBitUART(void)
{
char delay_time = (((((2*CLK)/(4*BAUD))+1)/2)-12)/10;
Delay10TCYx (delay_time/*124*/);
//return;
}
void DelayRXHalfBitUART(void)
{
char delay_time = (((((2*CLK)/(8*BAUD))+1)/2)-9)/10;
Delay10TCYx (delay_time/*306*/);
//return;
}
void DelayRXBitUART(void)
{
char delay_time = (((((2*CLK)/(4*BAUD))+1)/2)-14)/10;
Delay10TCYx (delay_time/*124*/);
//return;
}
/////////////////////////////////////////////////////////////
1. clock src from 96MHz PPL/2
2. OSC1/OSC2 src:/1, 96MHz PPL src:/2
3. divide by 5 (20MHz input)
4. Oscillator: HS:HS+PPL, USB-HS
5. Baud rate=9600
I'm using MPLAB C18.
At the begining PORTD value is 8 and then all the LEDs connected to that port are OFF. I never got the letter G on the hyper terminal and whenever I type a number OR letter on the hyper terminal I got someting else(which is not correct because whatever value recieved must be sent back) (e.g when typing 1 I got = and sometimes o) and never got 'Hello".
Waitnig for your replies.
Regards,