• 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.

Building a MIDI keytar


Active Member
The voltage dropped across the bridge should provide about 7.5V (roughly), which will go into a 7805.
That should keep it fairly cool. I have a LDO adjustable regulator (MIC2941A) which I'm going to set up for 3.3V.
I've given You a solution a few answers before ( TSR-1 ).

I just don't feel comfortable with driving
the MIDI out with the pin from a CPU directly
Search in the Internet about MiDi Thru Box.
You'll find some schematic how to interface a MiDi port.
As driver chips I would use 74HC... or 74HCT... Chips ( e.g. 74HC14 ).
They are faster then the old 40xxx one.


Well-Known Member
MJ Keep in mind my posts are based on 'OLD' parts ! electronics for most of my 'play time ' have been expensive ! so had to use what was in my 'stock' Note on Xtal / Osc , you need to achieve 31.25 kHz baud ,for MiDi


Active Member
granddad: That's <Exactly> what I'm doing as well. I'm using up my junk box parts. :)
The CPUs I could always reuse, especially if everything is socketed. And I'm careful with things like ESD.

And I remember that from the original MIDI spec. ;)

wkrug: Noted. :)


Active Member
LOL Back in the day, we were warned about wearing synthetics, because it could cause a static discharge.
These days I wear 'old lady undies', so it's not so important. :D

I wear cotton when I work at the bench too. :)


Active Member
Thanks granddad for letting me know about that. One less part in the finished PC board.

rjenkinsgb: I'm still going to pick up 5 pieces to tinker with. :)

I'd like to collect up as many parts as I can.
You never know what ideas come. If I have the parts handy, I'll breadboard up the circuit and test it out.

When I was in the industry, it was a drudge, and something that I had to do to get paid. Now, it's all about learning and having fun.

It sure beats needlepoint :D

I just found this thread. :)

I'd like to touch on the software development part. I'm about 7 days away from getting the PIC chip (on the 48 pin DIP header.)

I'm going to use MPLAB-X, but I really don't want to use C. Not that I can't program in C mind you, it just doesn't make sense for the task at hand.

Naturally, I spent a week or so, looking through the spec sheets and the XC16 Assembler reference.
(I got that PDF from here...Thanks to whomever posted it. :) )

So I created an empty project and added a new Assembler file.

It looks like this:
.include "p24F32KA304.inc"

    .global   __reset



This compiles fine. I did get stuck on writing config bits to the address of the feature registers.

I remember that there was a macro in MPLAB that allows you to set up the configuration bits at the top of the assembly source file.

So I went snooping around in p24F32KA304.inc. I found this

;   Configuration Words
;   Configuration words exist in Program Space and their locations are
;   defined in the device linker script. They can be set in source code
;   or in the MPLAB IDE. Each configuration word should be specified
;   only once (multiple settings may be combined.)
;  Setting configuration words using macros:
;  The following macro named 'config' can be used to set configuration words:
;  Please use #pragma in a separate C file in the project.
;  Some features in linker and compiler cannot use values
;  set using this method. Please migrate to #pragma config method.
The question is: Do I just ignore this and use the config macro anyway?
Or is there a trick to writing to the config memory while the CPU is running?

I have scoured the web looking for PIC24F KA examples, but have not found a single one.
They all say to use C.
Last edited:


Well-Known Member
They all say to use C.
Mmmm wonder why .. :) asm for PIC16 great fun, luv it .. have not ventured into the .asm 16 bit deep dark cold pool ... MPLAB X will generate CONFIG code.. as #pragma ...goto window - PIC memory views .. etc
Last edited:


Active Member
"I'm goin' in...cover me!" :D

I have to admit that for the majority of tasks, C is fine. But not in this specific case. I want to be able to tightly control the timing.
Not only that, but I want to completely get rid of the C Run-Time libraries. Building an app for an OS is one thing.
You have no choice but to use the tools that are available. But the PIC toolchain is GNU,
which means that you inherit their licensing issues whether you want them or not.

Or, worse yet, whether you -need- them or not.

Well it looks like I have some reading to do. Of course, if I find a suitable answer, I'll post it here. :)


Active Member
Seek and ye shall find. :D

User access to the program memory space is restricted
to the lower half of the address range (000000h to
7FFFFFh). The exception is the use of TBLRD/TBLWT
operations, which use TBLPAG<7> to permit access to
the Configuration bits and Device ID sections of the
configuration memory space.
Memory maps for the PIC24FV32KA304 family of
devices are shown in Figure 4-1
Is this why people are always screaming RTFM?


Well-Known Member
have to say my C would make a programmer cry... I have not ever used a library .. or MCC .. You can always slip in chunks of asm , Not tried it other than RTCC un locking.. or a SW reset ...


Active Member
Okay. I think I have it figured out. the config macro works fine but it emits a warning.
in the actual .inc file (p24f32ka304.inc), they say to do it this way, because the macro is deprecated.

           .section __FOSCSEL.sec, code
           .global __FOSCSEL
The flags aren't what I need, but I'll set that up when I get the PIC in. :)


Active Member
All of the parts have been ordered. Now, it's just a waiting game. The order with IDC box connector should be here today,
but I really can't do anything with it until I see what the CPU adapter looks like.

The CPU adapter already shipped from Canada, so it should take about a week to get here.

The next thing to consider is pitch bend, modulation, MIDI volume and buttons.

Latest threads

EE World Online Articles