• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic 16d628 Midi to USART

Status
Not open for further replies.

ivlenk

New Member
I can't get the USART to bring in MIDI DATA. It could be hardware, but I think that is correct so I am want to know if it's the code instead. Any ideas?


Paul

Code: (A0 led flashes on start up A1 is supposed to flash when midi bytes come in but it never does)

LIST P=16F628A
#include "P16F628A.INC"

__CONFIG _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON & _MCLRE_ON
CBLOCK 0x20
Loop1,Loop2
ENDC

radix hex
ORG 0x000

bcf STATUS,RP0
clrf PORTA
clrf PORTB
movlw 0x07
movwf CMCON

BSF STATUS,RP0
clrf TRISB
bsf TRISB,1
clrf TRISA
movlw 0x09
movwf SPBRG ; 31250 baud
bcf TXSTA,SYNC
bcf STATUS,RP0
bsf RCSTA,SPEN
bsf RCSTA,CREN
BSF PORTA,0 ; Blink LED to show chip is working
CALL delay
BCF PORTA,0
CALL delay

LOOP

btfss PIR1,RCIF ;Wait for RX flag
goto LOOP ;wait for USART byte

MOVF RCREG,W
BSF PORTA,1 ;flash second led to show usart in data
BCF PORTA,1
goto LOOP

delay MOVLW 0xf0
MOVWF Loop1
Outer MOVLW 0xc8
MOVWF Loop2
Inner NOP
NOP
DECFSZ Loop2,F
GOTO Inner
DECFSZ Loop1,F
GOTO Outer
RETURN

END
 

Pommie

Well-Known Member
Most Helpful Member
You will never see the second LED flashing as it is only on for 1uS. You need a delay between the lines,
Code:
        BSF     PORTA,1 ;flash second led to show usart in data
        BCF     PORTA,1
Mike.
 

ivlenk

New Member
Thanks Mike,
I had tried using delays, but my delay was too long to show activity (it added up to about 1 second) and when I tried the long delay I also didn't have the USART clock multiplier speed set correctly. Once I made a quicker delay function, I saw results. It needed to be just long enough to show light but short enough to catch midi activity successively. I appreciate the note!
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading

 
Top