|
|
View previous topic :: View next topic |
Author |
Message |
joe bob Guest
|
Prolific USB to Serial - PIC18F4685 - Pic transmit problems |
Posted: Sun Apr 26, 2009 8:25 pm |
|
|
I am using a PIC 18F4685, to receive and transmit data over rs-232. I am using the internal Oscillator.
At 32Mhz I have no problems when I use a normal serial port on my Desktop, transmit and receive both work fine at 38400baud. When I use my Prolific USB to serial converter most data being transmitted from the pic tends to get distorted/corrupted. I can't get it to even work at 9600.
I tried several versions of the Prolific driver, and several different pieces of PC side software.
I've tried many different baud rates on the pic side, different internal clock rates, all with the same result, I've stripped the code back to the basics.
I've used this Prolific device with another piece of PIC hardware unfortunately that I did not write and it functions.
So I'm stumped as to what I might be doing wrong on the PIC side that is affecting the transmission of data to the PC.
I have had issues with USB to serial converter before unrelated to this so I realize that not all USB to serial converters are created equal and some are better than others.
Any suggestions on things I can try to overcome this problem? Or am I coming up against this USB to serial converter?
Code: |
#include <18F4685.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES BBSIZ4K //4K words Boot Block size
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) //xmit=PIN_C6 |
Code: | #include "main.h"
int16 OverflowsTimer0=0;
int32 Overflows=0;
#INT_TIMER0
void TIMER0_isr()
{
OverflowsTimer0 += 1;
}
void main()
{
setup_oscillator(OSC_8MHZ);
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_4 );
set_timer0(0);
enable_interrupts( INT_TIMER0 );
enable_interrupts(GLOBAL);
Overflows = 0;
do{
if(OverflowsTimer0 > 3.517578125)
{ Overflows += 1;
putc('1');
OverflowsTimer0 = 0;
}
}while(true);
} |
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
handshaking |
Posted: Sun Apr 26, 2009 8:40 pm |
|
|
i'm guessing you are not enabling DTS/RTS hardware handshake ( you would have to manage DTR with an RS-232 voltage channel to do that ) OR XON /XOFF character handshake either
due to the Windows API translation function of a USB mapped "virtual" serial port - that could be eating your lunch at higher speeds -
OR you may have the receive ( on the PC) RX FIFO set to OFF or too low a buffer value)
it is almost certainly NOT the PIC code that is causing this.
BTW: add the ,ERRORS option to your CCS #use rs232 setup statement
IMPORTANT TO GET THAT RIGHT for PIC RX |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Apr 26, 2009 8:50 pm |
|
|
Install an 8 MHz crystal (and its capacitors). See if it works. If it does,
the problem is likely that the internal oscillator is not running at exactly
8 MHz. The 18F4685 data sheet says it can be up to 2% off at 25 deg. C,
and over temperature, it can be up to 5% off. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|