Hmm..
Can you post the whole code(s) and actual configs?
Must be something else the problem other than the lines shown.
Hmm..
Can you post the whole code(s) and actual configs?
Must be something else the problem other than the lines shown.
Dave
Always wear safety glasses while programming.
Here is the code use for 12F683
and code for 16F84A:Code:include "modedefs.bas" DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS ANSEL = %00111111 ' Set all to A/D, A/D clock = Frc TRISIO = %0011111 ' GP.5 = serial out, rest inputs OSCCON = %01100000 ' Internal 4MHz osc tmp var byte RESULT VAR word[8] ' 8-BYTE ARRAY STORAGE FOR 4 A/D CONVERSIONS J VAR BYTE ' A/D CHANNEL NUMBER BYTE VARIABLE resul var byte datain var GPIO.5 b var byte tmp = 0 MAIN: pause 1000 'Wait for 16F84A send data to LCD tmp = tmp + 1 if tmp > 9 then tmp = 0 for b = 1 to 4 serout2 datain,813,["B",dec tmp] next b goto MAIN
Code:include "modedefs.bas" rly VAR PORTB.7 'relay voltrelay var PORTB.6 'Relay Voltage control datain var PORTB.5 'Read serial data from adc sw1 VAR PORTB.0 sw2 VAR PORTB.1 cont2 VAR byte 'RESULT VAR word typ VAR BYTE b VAR BYTE 'If.. Then.. TRISA = %00000000 TRISB = %00000111 rly = 0 voltrelay = 0 b = 0 typ = 0 vslt: lcdout $fe, 1 pause 50 lcdout "1.Relay Voltage" serin2 datain,813,[WAIT("B"),cont2] lcdout $fe, $c0, "2.Enter", #cont2 goto vslt
Last edited by mackrackit; - 29th April 2010 at 08:29. Reason: Add Code Tags
Two things I see after a quick look...
You need to tell PBP what the OSC speed is. To do this add the following to the top portion of your code(s)
And double check the ANSEL settings.Code:DEFINE OSC 4
I think you have GPIO.5 set for analog. Should be
BTW. I added code tags for you. Makes it much easier to read on the forum.Code:ANSEL = %000011111
Dave
Always wear safety glasses while programming.
Still not working. I also try set all the port to digital (ANSEL = %00000000) still not showing anything on LCD. Hardware connection checked. Do you think is a hardware issue?
Hi, Kklim
could you " twist" somewhat the OSCTUNE register of the 683 ??? ... just to get a precise match with the '84 oscillator frequency ...
may be just use the " blinky led " program and trim the 683 osc frequency to that you've measured on the '84 ...
internal osc is " not so good " if you need frequ. matching ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Try changing serout2 datain,813,["B",dec tmp] to serout2 datain,813,["B", tmp]
Hi all,
I capture 2 waveform with a scope from 84A to 84A which work fine and 683 to 84A (no data) and Alain is correct, 683 waveform is shorter (Faster) then the 84A, after playing with the OSCTUNE, every 10 data send, only 1 data is show on the LCD. Also try change the Baud Rate from 813 to 1646 & 188, no data show.
Looks like device with internal clock is no good for sending data to a device with external clock![]()
Bookmarks