PDA

View Full Version : 12f675 serial pic2pic



tagan
- 12th March 2006, 21:55
I am trying send serial data pic 12f675 to 16f8777 and show this value on the lcd panel but it doesn't work. here is the program code. any ideas pls.
12f675:
INCLUDE "MODEDEFS.BAS"
@ DEVICE INTRC_OSC, WDT_OFF, MCLR_OFF, PWRT_ON
define osc_4
DEG VAR BYTE
CMCON=7
ANSEL=0
TRISIO.0=0
DEG=1
BASLA:
PAUSE 3000
SEROUT2 GPIO.0,16780,["A",DEG]
PAUSE 200
END
16f877:
INCLUDE "MODEDEFS.BAS"
define osc_4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_RWREG PORTB
DEFINE LCD_RWBIT 2
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEG VAR BYTE
ADCON1=7
TRISB=0
TRISC=1
LOW PORTB.2
PAUSE 100
LCDOUT $FE,1
PAUSE 100
BASLA:
SERIN2 PORTC.0,16780,[WAIT("A"),DEG]
PAUSE 200
LCDOUT $FE,2,#DEG
end

mister_e
- 12th March 2006, 22:33
could be many things here. But at least, can you confirm all of the following tests

Is a simple led blink work on both of your PIC
Is the LCD work on your 16F877


Another thing... is the SERIN Idle state may cause you a grief? idle what? look at the following post...
http://www.picbasic.co.uk/forum/showpost.php?p=9786&postcount=5

Be sure you set the transmitter pin to the corect state before sending something.

You DEFINE OSC is not correctly writen.. no problem anyway, it will not be considered. Chances are that the default OSC is 4. DEFINE spelling and writing is often discussed here... almost every week/month. They must be written as state in the manual, in UPPERCASE.
DEFINE OSC 4 without any underscore.

Also, when using 12Fs with internal osc in a serial comm, you should consider using the OSCCAL value to ensure a better Oscillator precision. Personnally i always use it, serial comm or not. it's just a simple code line after all

SET OSCCAL_1K 1

If you have a good device programmer, and if you're lucky, the OSCAL value is still there. To check it, just read your PIC and look at the last memory location... should different of 3fff

what else... maybe enough to start i guess

what about ...


' 12F675
@ DEVICE INTRC_OSC, WDT_OFF, MCLR_OFF, PWRT_ON
DEFINE OSCCAL_1K 1
DEG VAR BYTE
CMCON=7
ANSEL=0
TRISIO.0=0
GPIO.0=0 ' Set corect idle state
DEG=1

BASLA:
PAUSE 3000
SEROUT2 GPIO.0,16780,["A",DEG]
PAUSE 200
goto BASLA


You don't need to attach the R/W pin of your LCD to the PIC if you don't plan to read from. Just connect it to GND.

Dave
- 12th March 2006, 22:37
tagan, How long are you waiting after poweron for the 16f877 before you powerup the 12f675? I notice that you only send the data once and end the program execution. Maybe you are not waiting long enough for the LCD display to initialize before sending the data to it. I would place a delay before the data is sent to the LCD display and make sure the 16F877 is ready to receive the data before you send it.

Dave Purola,
N8NTA

tagan
- 12th March 2006, 22:54
thanks for your warning. I solve this problem change the mode 16789 to 396. yes you are right. it isnt necessarry to use portb.2 if I only write on the lcd . but it isnt my original program. it is a test. (can I use serial comminication) and get code for copy+paste from my previous program . also you are right about ossicilator. Iwill remove internal command. thanks all for I get your time and sorry for my bad english

mister_e
- 12th March 2006, 22:55
And oups i just notice something interesting in the 12F config file about the config fuses...


INTOSC equ 3FF80005h ; XX XXXX XXXX X101
INTRC_OSC_CLKOUT equ 3FF80005h ; XX XXXX XXXX X101
INTOSCIO equ 3FF80004h ; XX XXXX XXXX X100
INTRC_OSC_NOCLKOUT equ 3FF80004h ; XX XXXX XXXX X100


Where is the INTRC_OSC listed... oups. Might be another problem source.

EDIT: Great to know it's working now. Don't worry about your english... it could be reaaallllly worst. I'm french and it's hard for me as well.