PDA

View Full Version : Serin Problem with 12F629/PBP



Flyingms
- 4th March 2009, 21:40
Hello all,

I am having a devil of a time getting my SERIN to work with a 12F629. I connected the RS232 pin2 with a 1k resistor connected to pin7 of the 629, RS232 pin 3 with a 22.1k resistor to pin 6 of the 629, and RS232 pin 5 to pin8 of the 629. I am using a modified serqual PBP example program that writes Tom and Jerry to hyperterm. The output portion works fine... The input I keep banging my head on. I cannot get past the input.. I modified the original to turn off analog stuff gleaned from the archives. Also used a constant to load the pin number and directly set the port number. Any help would be appreciated..

George


' SERIN Command w/ Qualifiers
'
' "Crude" serial filter for C Style Comments

INCLUDE "modedefs.bas"
TRISIO.0 = 0
TRISIO.1 = 1
CMCON = 7
OPTION_REG.7 = 0
VRCON = 0

SO CON 0
SI CON 1
B0 VAR BYTE

SerOut 0,N2400,["TOM and JERRY",$D,$A]

wait1: SerIn SI,N2400,["//"],B0
SerOut 0,N2400,["Serial In RCVD",$D,$A]

loop: SerOut SO,N2400,[B0]
IF B0 = 13 Then wait1
SerIn SI,N2400,B0
GoTo loop

Archangel
- 5th March 2009, 00:25
I think I have never used serin successfully, therefore let me ask <b>you</b> an <u><font color = red><b>unqualified question:</u></b></font color> How many letters can you store in a single byte variable, like B0 ? And as I am leaving the house right now and do not have my manual handy, I may be all wet as to this line of questioning.

Flyingms
- 5th March 2009, 10:04
Joe,

Thanks for replying to my post. Of course, the single byte variable can only store one ascii charactor (char in C). One charactor is just enough to reply to a Yes/No ( Y )/( N ) query presented with SEROUT. Please understand that I am just trying to get this to work and will build on that... As of now, I cannot get past inputting a single char SERIN. I dont know if it is my hw implementation ( using MEL suggested resistors ), am missing something unique to 12F629 programming, or my serial port setup on the PC.

Further information about my configuration:
- Using a 4Mhz external resonator
- Selected XT on meProg..
- SEROUT working beautifully...
- Hyperterm set to 8N1 and receives ASCII from 629

Flyingms
- 5th March 2009, 11:34
Hello All,

I got SERIN to work.. I summized that my code was no different than half a dozen other 629/675 SERIN code snippets in the archives.. So I thought that maybe I was barking up the wrong tree ( code problem ). Maybe my problem was the input interface. I was using the MEL suggested 22k resistor ( 22.1k ) on the PIC input with no luck. I Googled "PIC RS232 Interface" and found multiple links that use only a 10k input resistor. I changed my input resistor to 10k and bang it worked...

Thanks everyone for the support. As I learn more, I hope to be an active member on this board.

George

timurak
- 7th March 2009, 21:30
I know little english.
I also have problems 12f675 serout2.
problem was solved by adding "define OSCCAL_1k 1".
Will benefit from this example that would send.
My my script below

@ device pic12f675, intrc_osc, wdt_on, bod_on, cpd_off, pwrt_on, mclr_off, protect_off

DEFINE OSCCAL_1k 1
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 10 ' Set sampling time in

CMCON = 7 ' Comparators OFF
ANSEL = %00100001 ' AN0 enabled (last 4 bits are enable bits {AN3:AN0}
ADCON0 = %11000001 ' VCC Vref / Turn On ADC Module
trisio = %001011 ' 1 giriş 0 Çıkış

SYMBOL AN_OKU = GPIO.0
SYMBOL TX = GPIO.5
VOLT VAR WORD

BASLA:
ADCIN AN_OKU, VOLT
pause 10
VOLT.highbyte = ADRESH
VOLT.lowbyte = ADRESL
SEROUT2 tx,16780 ,["volt : ", dec5 volt, ?10,?13 ]
pause 1000
GoTo basla

Flyingms
- 9th March 2009, 14:59
Thanks Timurak,

I didnt initially post it, but my platform uses the external 4 MHz. oscillator, but thank you for answering my post. I did fix the input problem with a change in the resistor from 22k to 10k. Now Serin is working flawlessly.

george