Gday,
I changed the items you found to be in correct. It still will not output what I send via RS232. It comes up with other numbers. I will repost the code I have ended up with below.
INCLUDE "modedefs.bas" ' Include serial modes
SI VAR PORTB.1 ' Serial Input pin
B0 VAR BYTE
Define OSC 10
Define LCD_DREG PORTA ' RA0..3
Define LCD_DBIT 0
Define LCD_RSREG PORTA ' RA6
Define LCD_RSBIT 6
Define LCD_EREG PORTA ' RA4
Define LCD_EBIT 4
Define LCD_BITS 4
TRISA = 0
TRISB = 0
CMCON = 7
Pause 1000 ' Wait for LCD to startup
duty VAR word ' Duty cycle value (CCPR3L:CCP3CON<5:4>)
TRISB.3 = 0 ' Set PORTB.5 (CCP3) to output
CCP1CON = %00001100 ' Set CCP3 to PWM
T2CON = %00000110 ' Turn on Timer2, Prescale=6
PR2 = 155 ' Set PR2 to get 1KHz out
duty = 125 ' Set duty cycle to 20%
loop:
SerIn SI,T9600,,# duty
if duty > 625 then
LCDOut $FE,1 ' Clear LCD screen
LCDOut "Duty to great" ' Display line 1
goto loop
endif
CCP1CON.4 = duty.0 ' Store duty to registers as
CCP1CON.5 = duty.1 ' a 10-bit word
CCPR1L = duty >> 2
'duty = duty + 5 ' Increase duty cycle
LCDOut $FE,1 ' Clear LCD screen
LCDOut # duty ' Display line 1
GoTo loop ' Do it forever
Any other ideas?
Thanks,
Ben
Bookmarks