Help setting baud rate for midi (31250)

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
clamrock
Posts: 3
Joined: Sat Oct 20, 2007 2:21 pm
Location: Michigan

Help setting baud rate for midi (31250)

Post by clamrock » Sat Oct 20, 2007 2:33 pm

Hi there,

I'm new to swordfish and am working on a project with an 18f252 with a 20mhz xtal. I need to set my baudrate to 31250 to send messages out via midi.

I see this isn't a standard baud in the usart module. What if anything to I need to do to use this baud rate?

Thank you in advance!

-Chris

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Sat Oct 20, 2007 2:56 pm

Are you planning to use the hardware UASRT or the software version, SUART?

And welcome to the forum!

Regards,

Steve

clamrock
Posts: 3
Joined: Sat Oct 20, 2007 2:21 pm
Location: Michigan

Post by clamrock » Sat Oct 20, 2007 3:15 pm

Well - right now I"m planning on using the harware USART - until I learn enough to know that maybe this wasn't the way to go! hehe Anyway I just now got it working...

I added....

br31250 as byte = FOSC / (FMULT * (31250 + 1)) - 1 + 0.5,

to the public const area of the usart.bas and renamed it midi_usart.bas to keep the original.

Loaded it up - programmed the pic and now I"m making music from the pic! yea!

Thanks for your prompt response - if you have any tips or tricks to do this better or smarter please let me know!

Thanks!

-Chris

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Sat Oct 20, 2007 3:47 pm

That's what I would have done, except if you save your modified version of the file with the original filename in your UserLibrary folder, the compiler will use this one in preference to the original - it saves you renaming it.

Good to hear that it is now working!

clamrock
Posts: 3
Joined: Sat Oct 20, 2007 2:21 pm
Location: Michigan

Post by clamrock » Sat Oct 20, 2007 4:34 pm

ahhh - sweet - that's what I'll do!

Thanks again for the help!

-Chris

Post Reply