How to HSERIN and MIDI code?


Closed Thread
Results 1 to 2 of 2
  1. #1
    francolok's Avatar
    francolok Guest

    Default How to HSERIN and MIDI code?

    How do I make to acquire data in entry with HSERIN to 31250 Baudrate with 20 MHz clock and PIC16f877?.I must handle the MIDI.
    Can someone help me?
    I'm try with this code...but no data!.... WHy?

    @ DEVICE HS_OSC
    DEFINE OSC 20
    B0 VAR BYTE
    B1 VAR BYTE
    BIT5 VAR BIT
    BIT4 VAR BIT
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD 31250
    DEFINE HSER_CLOERR 1

    TRISA = $85
    PORTA = $5
    TRISB = $86
    PORTB = $6
    TRISC = $87
    PORTC = $7
    TRISD = $88
    PORTD = $8
    TRISE = $ff
    PORTE = $9
    PIR1 = $0C
    TXREG = $19
    RCREG = $1A
    TXSTA = $98

    POKE TRISA, %11011111
    poke TRISB, %00000011
    poke TRISC, %10111111
    poke TRISD, %00000000
    poke TRISE, %00000011
    POKE PORTD, %00000000
    POKE PORTB, %00000000
    RCSTA = $90
    '-------------------------------------------------
    loop:
    Gosub charin
    If B1 = 0 Then loop
    Gosub charout
    Goto loop
    charin:
    B1 = 0
    BIT5 = PIR1 & $20
    If Bit5 = 0 Then ciret
    Peek RCREG,B1
    ciret:
    Return
    charout:
    BIT4 = PIR1 & $0F
    If Bit4 = 0 Then charout
    Poke TXREG,B1
    Return
    Last edited by francolok; - 18th December 2008 at 15:59.

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by francolok View Post
    DEFINE HSER_BAUD 31250
    Not sure if PBP/HSERIN/HSEROUT calculate baud rate or use a lookup table, but I'm sure that 31250 isn't a 'standard' baud rate. You may have to set the baud rate (SPBRG) manually, by hand, by doing a few calculations, looking it up in the 16F877 datasheet, etc.

    POKE TRISA, %11011111
    What's up with the POKEs and PEEKs when you can just access the registers directly like:
    RCSTA = $90

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. hserin and 16f876
    By novino in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th October 2009, 12:13
  3. SERIN MIDI out of Synch?
    By jncortes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th June 2009, 20:08
  4. HSERIN problem
    By eggman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th October 2007, 21:31
  5. Midi input, using hserin?
    By TonyA in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 26th June 2007, 12:18

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts