Hello Folks,
so at least I got it working. No loud laughs please, I'm too old to stand it.
Code is like this:
TX
'************************************************* ***************
'* Name : 16F88debug1 *
'* Author : MUGELPOWER/2 *
'* Notice : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 08.12.2017 *
'* Version : 1.0 *
'* Notes : WORKS! *
'* : *
'************************************************* ***************
Define OSC 4
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uSec
DEFINE DEBUG_REG PORTB
DEFINE DEBUG_BIT 2
DEFINE DEBUG_BAUD 2400
DEFINE DEBUG_MODE 0
DEFINE DEBUG_PACING 1000
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000010 ' Set PORTA analog
CMCON = 7 ' Disable analog comparator
ANSEL = %01000000 ' set AN6 (RB7) as analog, others to digital
RX VAR WORD
PAUSE 1000 ' lcd settle time
DEBUG 10,13
Main:
ADCIN 6,RX ' Read channel 6 (RB7)
DEBUG "*.*",DEC3 RX ,13,10 ' dec3 is important
Goto Main
End
RX:
'************************************************* ***************
'* Name : 16F876ADEBUGINa *
'* Author : MUGELPOWER/2 *
'* Notice : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 08.12.2017 *
'* Version : 1.0 *
'* Notes : WORKS! *
'* : *
'************************************************* ***************
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
' Set Debugin pin port
DEFINE DEBUGIN_REG PORTC
' Set Debugin pin bit
DEFINE DEBUGIN_BIT 7
' Set Debugin baud rate (same as Debug baud)
DEFINE DEBUG_BAUD 2400
' Set Debugin mode: 0 = true, 1 = inverted
DEFINE DEBUGIN_MODE 0
DEFINE osc 4
CMCON = 7
CVRCON = 0
adval VAR WORD
RX VAR word
TRISC = %10000000
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00000000 ' Set PORTB to all output
ADCON1 = %00000010 ' Set PORTA analog
Pause 1000 ' Wait 1 second
LCDOUT $FE, 2
LCDOUT $FE,$C0,"HELLO"
PAUSE 2000
Main:
DEBUGIN [WAIT("*.*"),DEC RX] 'dec is important
LCDOUT $FE, 2
pause 100
Lcdout $fe,$C0 ' Move cursor to beginning of second line
Lcdout "Ext=", DEC3 RX ' Display the decimal value
Goto main ' Do it forever
End
Two main problems before:
1. yes Scampy youre right: Main not Loop
2. ADCON1.7 = 1 had to be erased, after that the reciever shows 0 to 255 and not 0 to 3.
Thanks for your help.
Thanks Crownhill for the fast delivery of PBP3
Bookmarks