HELLO, CAN ANYONE HELP ME?
My code seems right, i have checked back again and again but i cannot get MIDIOX to recognise any messages. (it normaly recognises any message, so there must be something wrong with my code).
Can you see any mistakes here, or anything missed out?
running at 10 MHz, pic16f877, serial out from TX(C6).
[
LIST P=16F877
include "P16F877.INC"
;Define Registers Used
DelayTemp equ 20
DelayT2 equ 21
vel_1 equ 22
t_hold equ 23
movlw b'11111110' ;Make RB0 an output
tris PORTB
movlw b'10111111' ;Make RC6 an output
tris PORTC ; using the TRIState command
movlw b'00111111'
tris PORTA
bsf STATUS,RP0 ;set page 1
MOVLW 4 ;1 =spbrg value for 31.250 KHz @ 4 MHz clock
MOVWF SPBRG ;change to 4 if using 10MHz clock
MOVLW b'10100010' ;val for txsta 10100010 brgh = 0 (64 bit division)
MOVWF TXSTA ;asynchronous mode transmit enabled brgh low speed
BCF TRISC,6 ;set RC6 as output
BCF PIE1,4 ;clear transmit interrupt
movlw 00h
movwf ADCON1
bcf STATUS,RP0 ;set back to page 0
MOVLW B'10010000' ;val for rcsta 10010000 serial port enabled
MOVWF RCSTA
movlw B'10000001' ; A/D is on, Channel 0 is selected
movwf ADCON0
movlw D'25'
movwf t_hold
call Delay
main
bsf ADCON0,GO ; Start A/D Conversion:
check_1
btfsc ADCON0,GO
goto check_1
movf ADRESH,W
movwf vel_1
movf vel_1,w ;compare vel_1 with
subwf t_hold, W ;threshold
btfss STATUS, C ;skip if vel_1<t_hold
goto loop ;go flash
goto main
loop
MOVLW 90H ;note on channel 1
MOVF TXREG ;transmit
CALL Delay
MOVLW 45H ;note A 4
MOVF TXREG ;transmit
CALL Delay
MOVLW 64H ;velocity 64
MOVF TXREG ;transmit
bsf PORTB,0 ;Set LED On
call LongDelay ;Delay to make blink visible
bcf PORTB,0 ;Set LED Off
goto main
;*******************************************************************
; Internal functions
;*******************************************************************
LongDelay ;Approx 125 mS delay
movlw .255
movwf DelayT2
ldelaya
call Delay
decfsz DelayT2,f ;Decrement this register and
goto ldelaya ; keep going until it hits zero
return
Delay ;Short delay
movlw .255 ;Load Temp register with constant for .3 ms
movwf DelayTemp
delaya
decfsz DelayTemp,f ;Decrement until zero
goto delaya
return
END
]
thanks
Bear[/code]
My code seems right, i have checked back again and again but i cannot get MIDIOX to recognise any messages. (it normaly recognises any message, so there must be something wrong with my code).
Can you see any mistakes here, or anything missed out?
running at 10 MHz, pic16f877, serial out from TX(C6).
[
LIST P=16F877
include "P16F877.INC"
;Define Registers Used
DelayTemp equ 20
DelayT2 equ 21
vel_1 equ 22
t_hold equ 23
movlw b'11111110' ;Make RB0 an output
tris PORTB
movlw b'10111111' ;Make RC6 an output
tris PORTC ; using the TRIState command
movlw b'00111111'
tris PORTA
bsf STATUS,RP0 ;set page 1
MOVLW 4 ;1 =spbrg value for 31.250 KHz @ 4 MHz clock
MOVWF SPBRG ;change to 4 if using 10MHz clock
MOVLW b'10100010' ;val for txsta 10100010 brgh = 0 (64 bit division)
MOVWF TXSTA ;asynchronous mode transmit enabled brgh low speed
BCF TRISC,6 ;set RC6 as output
BCF PIE1,4 ;clear transmit interrupt
movlw 00h
movwf ADCON1
bcf STATUS,RP0 ;set back to page 0
MOVLW B'10010000' ;val for rcsta 10010000 serial port enabled
MOVWF RCSTA
movlw B'10000001' ; A/D is on, Channel 0 is selected
movwf ADCON0
movlw D'25'
movwf t_hold
call Delay
main
bsf ADCON0,GO ; Start A/D Conversion:
check_1
btfsc ADCON0,GO
goto check_1
movf ADRESH,W
movwf vel_1
movf vel_1,w ;compare vel_1 with
subwf t_hold, W ;threshold
btfss STATUS, C ;skip if vel_1<t_hold
goto loop ;go flash
goto main
loop
MOVLW 90H ;note on channel 1
MOVF TXREG ;transmit
CALL Delay
MOVLW 45H ;note A 4
MOVF TXREG ;transmit
CALL Delay
MOVLW 64H ;velocity 64
MOVF TXREG ;transmit
bsf PORTB,0 ;Set LED On
call LongDelay ;Delay to make blink visible
bcf PORTB,0 ;Set LED Off
goto main
;*******************************************************************
; Internal functions
;*******************************************************************
LongDelay ;Approx 125 mS delay
movlw .255
movwf DelayT2
ldelaya
call Delay
decfsz DelayT2,f ;Decrement this register and
goto ldelaya ; keep going until it hits zero
return
Delay ;Short delay
movlw .255 ;Load Temp register with constant for .3 ms
movwf DelayTemp
delaya
decfsz DelayTemp,f ;Decrement until zero
goto delaya
return
END
]
thanks
Bear[/code]