you can't be doing it the right wayIn my experience the use of multiple IF...THEN slows my 40 MHz PIC down to pure uselessness...
you can't be doing it the right wayIn my experience the use of multiple IF...THEN slows my 40 MHz PIC down to pure uselessness...
Hello Guys,
need alittlehelp because iīm totally stuck.
Trying to send one byte from a PIC16F876A to a PIC16F88 and display it.
Tried Debug,Serin and donīt get it working.
Everything works in the proram exept the serout - serin communication.Tried with pullup resistor, baud rates from 1200 to 9600, negative and true.....tried to get samples from this forum, tried samples out of several PIC programming books, I donīt get it.
Hello World2serin.txtADCINBargraphserout.txtHello World2serin.txt
Hello folks,
please help because Iīm totally stuck.
Try to send one byte from a 16F88 to a 16F876A and display it on LCD using DEBUG.
16F88 measures voltage on one pin and send the variable adval to 16F876A.
Problem is: the LCD at the 16F876A shows only 4 different charcters: 48 up to 51 or if I change from DEC3 to DEC1 0 to 3.
Should be 0 to 255 . The Voltage at the analog Input goes the full way from 0V to 4.8V but the LCD shows only 4 different characters which change at about 1/4 of the voltage change, so its proportional to the voltage change .
I get the message "some configuration words are not in hex" from my PICKIT2 but only when programming the 16F88.
Transmitter:
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 01.03.2012 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
'************************************************* ***************
'* Name : AnalogDEBUG *
'* Author : [Davidpower] *
'* [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 05.12.2017 *
'* Version : 1.0 *
'* Notes : 16F88 no LCD *
'* : Portb.7 analog IN 0-5V *
'************************************************* ***************
Include "modedefs.bas"
Define OSC 4
Define ADC_BITS 4 ' 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
CMCON = 7 ' Disable analog comparator
ANSEL = %01000000 ' set AN6 (RB7) as analog, others to digital
ADCON1.7 = 1 ' Right justified results... duh... really needed in 8 bits???
adval VAR WORD
PAUSE 1000 ' lcd settle time
DEBUG 10,13
loop:
ADCIN 6,adval ' Read channel 6 (RB7)
DEBUG #adval
Pause 100
Goto loop
End
Receiver:
'************************************************* ****************************
'* MICROCODE STUDIO TIPS *
'* *
'* (1) : To get context sensitive help, move your cursor to a PICBasic *
'* : command and then press F1. *
'* (2) : Program assumes the PIC is running at 4MHz. To change the default *
'* : setting (for example, to 20MHz) simply add DEFINE OSC 20 at the *
'* : top of your program. *
'* 16F876A 4zeiliges Display, 4 analoge eingänge *
'* DEBUG PORTB.0
'This sample program is supplied courtesy of microEngineering Labs Inc *
'************************************************* ****************************
' PicBasic Pro program to display result of
' 8-bit A/D conversion on LCD
' Connect analog input to channel-0 (RA0)
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
DEFINE DEBUGIN_REG PORTC
DEFINE DEBUGIN_BIT 7
DEFINE DEBUG_BAUD 2400
DEFINE DEBUGIN_Mode 1
DEFINE osc 4
Include "modedefs.bas"
CMCON = 7
CVRCON = 0
adval 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 .5 second
LCDOUT $FE, 2
loop:
DEBUGIN 1000,timeout,[adval]
pause 50
timeout
LCDOUT $FE, 2
Lcdout $fe,$C0 ' Move cursor to beginning of second line
Lcdout "Ext ", DEC3 adval ' Display the decimal value
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
End
Bookmarks