if serout2 was inverted, HSER is not inverted. 16416 in table shows inverted.
if serout2 was inverted, HSER is not inverted. 16416 in table shows inverted.
Last edited by amgen; - 16th October 2011 at 19:40.
Is there any way to set the DEBUG baud rate at runtime?
Sorry, I don't understand what you want me to do?! I don't have any problems with SEROUT2 at this time.Originally Posted by amgen
I did try this at all available baudrates; never worked. Before you ask, yes, I tried with another PICOriginally Posted by Charles Linquis
I do use a PIC16F690 and modified the code with your suggestion as it is herunder:As said, I tried also the lowest selectable baudrate 300bps; even so, I can't see any "good" data in the terminal.Code:' HSEROUT ' PIC 16F690 Fuses @ __Config _FCMEN_OFF &_IESO_OFF &_BOR_OFF &_CPD_OFF &_CP_OFF &_MCLRE_OFF &_PWRTE_OFF &_WDT_OFF &_HS_OSC OPTION_REG = %10000000 'PORT A&B Pull-Ups (look WPUA & WPUB) ADCON0 = %00000000 'A/D Module ANSEL = %00000000 'Select analog inputs Channels 0 to 7 ANSELH = %00000000 'Select analog inputs Channels 8 to 11 INTCON = %00000000 'INTERRUPT Control 'WPUA = %00000000 'Select PORTA weak pull-ups 'IOCA = %00000000 'Interrupt On Change selection CM1CON0 = %00000000 'Comparator1 Module CM2CON0 = %00000000 'Comparator2 Module TRISA = %00000000 'Set Input/Output (0 to 5) PORTA = %00000000 'Ports High/Low (0 to 5) TRISB = %00000000 'Set Input/Output (4 to 7) PORTB = %00000000 'Ports High/Low (4 to 7) TRISC = %00000000 'Set Input/Output (0 to 7) PORTC = %00000000 'Ports High/Low (0 to 7) '------------------------------------------------------------------------------- ' DEFINEs DEFINE OSC 20 RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 SPBRG = 42 ' 115200 Baud @ 20MHz, 0.94% BAUDCTL.3 = 1 'for PIC16F690 - BAUDCON1.3 = 1 ' Enable 16 bit baudrate generator '------------------------------------------------------------------------------- LED1 var PORTA.2 Counter var word Counter = 0 TEST: Toggle led1 HSEROUT [dec counter,13,10] pause 500 Counter = counter + 1 goto test end
Roger
back to basic Roger... check your ANSEL(h) settings.. you're sending something on a analog configured pin.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
are you using a USB to serial converter ?
Why didn't you SHOUT IT OUT LOUD!!??
You're absolutely right: the signal has to be inverted in the way I'm using it. I added a transistor to invert the signal going to the MAX232 chip and guess what: IT WORKS!!!!
The HSEROUT code example in one of my previous post is working fine, also with 115200bps.
I still have some transmission errors but I think this can be due to the small error rate - I'll try with a 18,432MHz crystal.
Thanks a lot and have a nice day.
Roger
Hi there,
I need to use a 18,432MHz crystal with this PIC16F690 project to achieve a clean 115200bps serial comm.
Looking at the OSC values in the DEFINEs list, I can't find the value "18".
Shall I simply define the OSC as, i.e., "20" while connecting a 18MHZ crystal?
The only drawback I can see is about timing in PAUSE commands or similar. I assume the HUSART will still run from the 18MHz osc; right?
Any other problems I wouldn't see?
Roger
I don't like to yell because I'm usually wrong.Why didn't you SHOUT IT OUT LOUD!!??
Just a few thoughts, the Max232 chip inverts signal, if your using USB to serial adapter, that takes a non-inverted signal, so you may be inverting redundently. Also, have you tried OSC-Tune to adjust clock to good 115Kb, then you can use standard Xtal ?
Don
Yes, I do use a USB-to-serial interface (FTDI).
I now corrected the BAUDCTL register so as it sends data inverted (no need for a hw inverter anymore).
As far as I understand this register's function, OSCTUNE calibrates the internal oscillator so I don't think it will affect the baud rate generator (I don't know).
BTW, how do I measure a "good" 115200bps signal?
Code:' HSEROUT ' PIC 16F690 Fuses @ __Config _FCMEN_OFF &_IESO_OFF &_BOR_OFF &_CPD_OFF &_CP_OFF &_MCLRE_OFF &_PWRTE_OFF &_WDT_OFF &_HS_OSC OPTION_REG = %10000000 'PORT A&B Pull-Ups (look WPUA & WPUB) ADCON0 = %00000000 'A/D Module ANSEL = %00000000 'Select analog inputs Channels 0 to 7 ANSELH = %00000000 'Select analog inputs Channels 8 to 11 INTCON = %00000000 'INTERRUPT Control 'WPUA = %00000000 'Select PORTA weak pull-ups 'IOCA = %00000000 'Interrupt On Change selection CM1CON0 = %00000000 'Comparator1 Module CM2CON0 = %00000000 'Comparator2 Module TRISA = %00000000 'Set Input/Output (0 to 5) PORTA = %00000000 'Ports High/Low (0 to 5) TRISB = %00000000 'Set Input/Output (4 to 7) PORTB = %00000000 'Ports High/Low (4 to 7) TRISC = %00000000 'Set Input/Output (0 to 7) PORTC = %00000000 'Ports High/Low (0 to 7) '------------------------------------------------------------------------------- ' DEFINEs DEFINE OSC 20 RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 SPBRG = 42 ' 115200 Baud @ 20MHz, 0.94% BAUDCTL = 24 'Transmit INVERTED data to RB7, Enable 16 bit baudrate generator '------------------------------------------------------------------------------- LED1 var PORTA.2 Counter var word Counter = 0 TEST: Toggle led1 HSEROUT [dec counter,13,10] pause 500 Counter = counter + 1 goto test end
Roger
The baud rate generator will be accurate. If the formula says you will get 115KBaud with a 20Mhz oscillator, you will.
If you don't get 115K baud, then you aren't really running at 20Mhz, or the receiving device has an issue.
I mentioned in another post how to measure just how fast your chip is running - without an oscilloscope.
(Turn LED ON)
For X = 1 to 60
Pause 60000
Next X
(Turn LED OFF)
Wait one hour. If your LED goes off in exactly 60 minutes, your chip is running the speed you think it is. Using a
calculator, you can measure the actual frequency to about 0.1%
A useful tool is BRAY's TERMINAL program (Google it). Free, and it lets you set odd baud rates, like 113Kbaud.
or 120Kbaud.
Charles Linquist
Can anyone give some info about this please?I need to use a 18,432MHz crystal...
Looking at the OSC values in the DEFINEs list, I can't find the value "18".
Shall I simply define the OSC as, i.e., "20" while connecting a 18MHZ crystal?
Roger
Does really nobody know something about that?I need to use a 18,432MHz crystal...
Looking at the OSC values in the DEFINEs list, I can't find the value "18".
Shall I simply define the OSC as, i.e., "20" while connecting a 18MHZ crystal?
Roger
You are going to have to unless you change the libraries. Just remember that any PAUSE commands will be 8.5% longer than you think.
You can get around that by creating some variables.
For example: If your program needed 3 different delays 20ms, 50ms, 190ms
You would create 3 vars
delay20 con 18
delay50 con 46
delay190 con 175
Now, if you need a 20mSec delay, you can use the command
PAUSE delay20
It is not exact, but it is close.
Charles Linquist
Thanks Charles,
I thought this would happen. No problem then, for me ;-)
Roger
Bookmarks