If I'm using RA0, do I need to set those registers? Because without them the screen is completely blank:
Edit: AddingCode:'**************************************************************** '* Name : Test_SPWM.pbp * '* Author : Darrel Taylor * '* Date : 9/30/2006 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** ; LCD serout2 command won't work when using interrupts; need to use ; HSEROUT on chip's USART tx pin instead. ' *************************************************************** ' Pin Connections ' *************************************************************** ' RA0 -> Serial LCD output ' RA1 -> Middle arm of trim pot (AN1) ' RC0 -> LED1 ' RC1 -> LED2 ' RC2 -> LED3 DEFINE OSC 16 ; Set oscillator 16Mhz ;DEFINE OSC 4 ; Set oscillator 4Mhz DEFINE ADC_BITS 8 ; Set number of bits in result DEFINE ADC_SAMPLEUS 5 ; Set sampling time in uS DEFINE ADC_CLOCK 3 ; Set clock source (3=rc) DEFINE HSER_TXSTA 20h ; Set transmit status and control register DEFINE HSER_BAUD 2400 ; Set baud rate ' *************************************************************** ' Device Fuses ' *************************************************************** #CONFIG __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF __config _CONFIG2, _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF #ENDCONFIG #DEFINE USE_LCD_FOR_DEBUG ; comment out for non-debug use ' *************************************************************** ' Initialization ' *************************************************************** OSCCON = %01111000 ' 16MHz internal osc ;OSCCON = %01101000 ' 4MHz internal osc pause 100 ; Use PortA.1 (AN1) for ADCIN (trim pot reading) ANSELA = %00000010 ; Analog on PORTA.1 (AN1) only TRISA = %00000010 ; Input on PORTA.1 (AN1) only ;ADCON1 = %01110000 ; Left-justified results in 8-bits; Fosc/8 (2uS @ 4Mhz) ADCON1.7 = 0 ; Left-justified results in 8-bits; Fosc/8 (2uS @ 4Mhz) ANSELC = 0 ; Diginal only for all PortC pins TRISC = %00000000 ; Make all PORTC pins output #DEFINE USE_LCD_FOR_DEBUG ; comment out for non-debug use #IFDEF USE_LCD_FOR_DEBUG LCD_PIN VAR PORTC.4 ' Alias PORTC.4 as "LCD_PIN" LCD_INST CON 254 ' instruction LCD_CLR CON 1 ' Clear screen LCD_L1 CON 128 ' LCD line 1 LCD_L2 CON 192 ' LCD line 2 LCD_BAUD CON 16780 ' Baud rate/mode 2600bps for ILM-216 2x16 character display ; LCD_BAUD CON 16468 ' Baud rate/mode 9600bps for ILM-216 2x16 character display LCD_PACE CON 1 ' Optional pace value #ENDIF ' *************************************************************** ' Includes ' *************************************************************** INCLUDE "DT_INTS-14.bas" ; Base Interrupt System INCLUDE "SPWM_INT.bas" ; Software PWM module DEFINE SPWM_FREQ 200 ; SPWM Frequency DEFINE SPWM_RES 256 ; SPWM Resolution DutyVars VAR BYTE[3] ; DutyCycle Variables DutyVar1 VAR DutyVars[0] ; group them in an array for easy access DutyVar2 VAR DutyVars[1] ; with FOR loops etc. DutyVar3 VAR DutyVars[2] ASM SPWM_LIST macro ; Define Pin's to use for SPWM SPWM_PIN PORTC, 0, _DutyVar1 ; and the associated DutyCycle variables SPWM_PIN PORTC, 1, _DutyVar2 ; Notice the underscore before variables SPWM_PIN PORTC, 2, _DutyVar3 endm SPWM_INIT SPWM_LIST ; Initialize the Pins ENDASM ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, SPWMhandler, ASM, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts adval VAR WORD ; stores ADCIN results oldDutyVar1 VAR WORD ;_____________________________________________________________________________ DutyVar1 = 0 DutyVar2 = 25 DutyVar3 = 255 #IFDEF USE_LCD_FOR_DEBUG HSEROUT [LCD_INST, LCD_CLR] pause 5 HSEROUT ["DutyVar1=", DEC DutyVar1, 13, 10] ' Send text followed by carriage return and linefeed #ENDIF Main: ADCIN 1, adval if adval <> oldDutyVar1 then oldDutyVar1 = adval DutyVar1 = adval #IFDEF USE_LCD_FOR_DEBUG HSEROUT [DEC DutyVar1, 13, 10] ' Send text followed by carriage return and linefeed #ENDIF EndIf Pause 100 Goto Main
makes the screen not blank, but it's still gobbledy-gook.Code:APFCON0.2 = 1 ; Tx on RA0




Bookmarks