Jump to content

firmware baudrate experiments -> USB


*jOi~

Recommended Posts

Hi folks,

I've had a little box here working w/ a FT232 USB chip for a while now, and it's about time I delve a little further into the possibilities of using MIDI over USB. I'm planning to write up a driver using either chuck, or a small MaxMSP application, though this is probably still a few months off.

My question is something that I have touched upon in previous questions, but never got a full answer. What I am looking for is the point in the bootloader firmware that I can modify to allow baudrates other than MIDI and To-COM. My plan is to alter the To-COM value and for it to become To-USB running at 115.2 kbps.

Whilst I've been learning a lot about java (and similar languages) I'm still useless working with assembler, and staring at hex values continues to mystify me. If anyone could point to the register that must be changed, I will experiment with the value and investigate the effects of different baudrates - see if i can cause problems w/ overloading the I/O buffer.

Thanks for the help friends

Trent

Edit: I believe this is the spot, but I have little clue how to interpret the hex values, and what they should become..

movlw (1 << TXEN) | (1 << BRGH)

movwf TXSTA

IFCLR MIOS_BOX_CFG0, MIOS_BOX_CFG0_TO_HOST, goto Init_USART_MIDIBaudrate

Init_USART_RS232Baudrate

  movlw 2*0x21-1 ; set baudrate to 38400 baud

IFSET MIOS_BOX_CFG0, MIOS_BOX_CFG0_20MHz, movlw 0x21-1

goto Init_USART_Cont

Init_USART_MIDIBaudrate

movlw 8*0x0a-1 ; set baudrate to 31250 baud

IFSET MIOS_BOX_CFG0, MIOS_BOX_CFG0_20MHz, movlw 4*0x0a-1

;; goto Init_USART_Cont

Link to comment
Share on other sites

You're on the right path, just grab a copy of the datasheet for the PIC, and play follow the code.

If you convert the hex values to binary (you can use something like PMACalc if you don't like doing it in your head) and look up the registers in the datasheet, it will all make sense.

Link to comment
Share on other sites

thanks for the direction stryd... i get the feeling that i will figure this out, but after the first half hour of staring at that datasheet, im glad there is no deadline hanging over my head to get it finished.

the answer is there, i can see it, i just read it, all i need now is to understand it.

cheers

Link to comment
Share on other sites

success!.. well the beginnings of..

after ~6hrs of study i know a huge amount more about the beauty of PICs and how they function, assembler is beginning to make sense, and I discovered the all important meaning of 2*0x21-1....

the simple answer = (2 * 33) - 1 = 65

how does 65 give a baudrate of 38400? only the PIC datasheet knows the answer..

'79' gives 31250

'65' gives 38400

'21' gives 115200

my new line is therefore: 2*0x0b-1

i finally used MPLAB (which i installed ca. 12mths ago) and compiled my code. my brand new PIC burner has 2 fresh PICs for me now - one with the standard TO-COM 38400 baud (which I know is working), and a second with TO-USB 115200 with which I will now experiment.

Next tasks are not the easiest - trying to decipher the way Max/MSP handles SysEx commands, so I can upload MIOS - the joys of uncharted waters with a lack of available drivers..

I'll keep you updated

trent

Link to comment
Share on other sites

ergg... apologies but in fact, the magic number is '21', and so 2*0x0b-1 should be right. Thanks for picking me up Therezin..

I wish you were right though, and I'd been careless in my decimal > hex conversion, but alas the PIC is programmed correctly and yet I can't get applications to upload correctly.

Running MIOS Studio via Max/MSP w/ the serial object (and MIDI Yoke), and whilst I had no troubles uploading MIOS to both PICs, I could only get my app to upload correctly to the chip at 38400. Nevertheless, I have successfully got the 38400 PIC running my led/button matrix program (c/o Wilba) without any serial cable or MIDI port.

Sometimes it is easy to forget the small goals when you fall short of the large ones, but I have just proved to myself that it is possible to run a MBHP with only a PIC burner and a cheap/small USB chip. This is still a Max/MSP reliant implementation.

Developments soon..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...