i have done a program with .asm extension for my project. i have assembled it and have no errors. after this i created a hex file using Quickbuild in MPLAB IDE version 8.43 and still no problem. the program is supposed to accept a DMX512 signal from a console and then control a PIC16F876 to produce a dimmable light using pulse width modulation.
the programmer i mnaged to get is a Velleman K8048 whic is supposed to program the pic without any problems. when i load the hex file, it does not give me the message to indicate that the pic was programmed successfully.
does my program have anything to do with this?
please help
i have included the .asm file
;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC16F876.
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: charles01 *
; Files Required: P16F876.INC *
;
; Notes: DMX512 demo program for an LED light to respond to the DMX signal *
;
;*********
list p=16f876 ; list directive to define processor
#include <p16f876.inc> ; processor specific variable definitions
errorlevel -302
;*****
__CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _RC_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF
;*****
#define CHANNEL .000 ;select the receiver slot/channel
;*****
;***** VARIABLE DEFINITIONS
w_temp EQU 0x7E ; variable used for context saving
status_temp EQU 0x7F ; variable used for context saving
CBLOCK 0x20
CountH ;16-bit counter
CountL
RxBuffer: .512 ;512 bytes buffer allocation
ENDC
;**********************************************************************
ORG 0x000 ; processor reset vector
clrf PCLATH ; ensure page bits are cleared
goto main ; go to beginning of program
;*****
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
; isr code can go here or be located as a call subroutine elsewhere
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
;*****
main
call SetupSerial ;Setup Serial port and buffers
;******************************************************************************
Start
; first loop, synchronizing with the transmitter
WaitBreak
btfsc PIR1,RCIF ; if a byte is received correctly
movf RCREG,W ; discard it
btfss RCSTA,FERR ; else
goto WaitBreak ; continue waiting until a frame error is detected
movf RCREG,W ; read the Receive buffer to clear the error condition
;second loop, waiting for the START code
WaitForStart
btfss PIR1,RCIF ; wait until a byte is correctly received
goto WaitForStart
btfsc RCSTA,FERR
goto WaitForStart
movf RCREG,W
; check for the START code value, if it is not 0, ignore the rest of the frame
andlw 0xff
bnz Start ; ignore the rest of the frame if not zero
; init receive counter and buffer pointer
clrf CountL
clrf CountH
;; clrf RxBuf
clrf RCREG; third loop, receiving 512 bytes of data
WaitForData
btfsc RCSTA,FERR ; if a new framing error is detected (error or short frame)
goto RXend ; the rest of the frame is ignored and a new synchronization is
; attempted
btfss PIR1,RCIF ; wait until a byte is correctly received
goto WaitForData ;
movf RCREG,W ; MoveData
movwf RxBuffer ; move the received data to the buffer
; (auto-incrementing pointer)
incf CountL,F ; increment 16-bit counter
btfss STATUS,C
goto WaitForData
incf CountH,F
btfss CountH,1 ; check if 512 bytes of data received
goto WaitForData
;******************************************************************************
; when a complete frame is received
; use the selected CHANNEL data to control the CCP1 & CCP2 module duty cycle
RXend
clrf RxBuffer ; use indirect pointer 0 to address the receiver buffer
GetData
movlw LOW(CHANNEL) ; add the offset for the select channel
addwf FSR,F
movlw HIGH(CHANNEL)
addwf FSR,F
;; movwf INDF,CCPR2L ; retrieve the data and assign MSB to control PWM2
;; movwf INDF,CCPR1L ; retreive the data and assign MSB to control PWM1
movlw INDF
movwf CCPR2L ; retreive the data and assign MSB to control PWM2
;*****
movlw INDF
movwf CCPR1L ; retreive the data and assign MSB to control PWM1
;*****
goto Start ; return to main loop
;******************************************************************************
; Setup Serial port and buffers
SetupSerial
; Clear the receive buffer
;*****
clrf RxBuffer
CBloop
clrf RxBuffer ; clear INDF register then increment pointer
incf CountL,F
btfss STATUS,C
goto CBloop
incf CountH,F
btfss CountH,1
goto CBloop
; Setup EUSART
banksel TRISC
;; bsf TRISC,7 ;B'10000000' ; allow the EUSART RX to control pin RC7
;; bsf TRISC,B'10000000'; allow the EUSART TX to control pin RC6
movlw B'11000000'
movwf TRISC
movlw 0x04 ; Disable transmission
movwf TXSTA ; enable transmission and CLEAR high baud rate
movlw 0x90
movwf RCSTA ; enable serial port and reception
;; bsf BAUDCON,BRG16 ; Enable UART for 16-bit Asyn operation
bsf TXSTA,BRGH
clrf SPBRG
movlw .15 ; Baud rate is 250KHz for 16MHz Osc. freq.
movwf SPBRG
; Setup PWM module
movf CCP1CON,W ; configure CCP1 for PWM mode
andlw 0xF0
iorlw 0x0C
movwf CCP1CON
;*****
movf CCP2CON,W ; set CCP2 as PWM mode
andlw 0xF0
iorlw 0x0C
movwf CCP2CON
;*****
; Timer1 control
movf T1CON,W ; configure Timer1 to oscilation
andlw 0x09
iorlw 0x04
movwf T1CON
;Timer2 control
movlw 0x04 ; enable Timer2, select a prescale of 1:1
movwf T2CON
; PWM period
movlw 0xFF ; 256 x .25us = 64us period
movwf PR2
; init I/O
banksel TRISA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; bsf TRISA;;;;;;;;;;;;;
movlw 0x00
movwf TRISA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
movlw b'11111111' ; make pins on PortA inputs
movwf PORTA
;int I/O
banksel TRISB
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; bsf TRISB;;;;;;;;;;;;
movlw 0x00
movwf TRISB
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
movlw b'11111111' ; make pins on PortB inputs
movwf PORTB
;init I/O
banksel TRISC
;; bsf TRISC;;;;;;;;;;;;;;
movlw 0x00
movwf TRISC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
movlw b'11110111' ; make pin RC2 (CCP2) output
movwf PORTC
return
;*****
END ; directive 'end of program'