Jump to content

Scan matrix


bill

Recommended Posts

Hello,

i definitely need help :

i want to use the scan-matrix driver http://ucapps.de/mios/sm_example2_v1.zip

with C, (in order to drive the C64 keyboard http://www.midibox.org/forum/index.php?topic=6505.msg41509#msg41509) but i really dont know how to mix asm and C

I tried to put required files into ./mios_wrapper/

and include them into mios_wrapper.asm with no chance

i have those errors :

Assembling MIOS SDCC wrapper
mios_wrapper\sm_simple.inc:193:Error [103] syntax error
mios_wrapper\sm_simple.inc:194:Error [103] syntax error
mios_wrapper\sm_simple.inc:195:Error [103] syntax error
mios_wrapper\sm_simple.inc:196:Error [103] syntax error
mios_wrapper\sm_simple.inc:197:Error [103] syntax error
mios_wrapper\sm_simple.inc:198:Error [103] syntax error
mios_wrapper\sm_simple.inc:199:Error [103] syntax error
mios_wrapper\sm_simple.inc:200:Error [103] syntax error
mios_wrapper\sm_simple.inc:204:Error [103] syntax error
mios_wrapper\sm_simple.inc:313:Error [103] syntax error
mios_wrapper\midi_evnt.inc:101:Error [103] syntax error

mios_wrapper\macros.h:90:Error [151] Operand contains unresolvable labels or is too complex.
mios_wrapper\macros.h:92:Error [151] Operand contains unresolvable labels or is too complex.
mios_wrapper\midi_evnt.inc:271:Error [151] Operand contains unresolvable labels or is too complex.
mios_wrapper\midi_evnt.inc:274:Error [151] Operand contains unresolvable labels or is too complex.
ERROR!

PLease help me if you can  :-[

Link to comment
Share on other sites

well, I can't ASM and I don't know the example besides having taken a quick look.

It seems that the SM_Stuff is that what you want to have, it shouldn't be very complicated but maybe a bit time-consuming to wrap it into a C-file with __asm and __endasm.

on the other hand there are two more options:

1. convert the whole asm project to C (I think most of the smaller projects will be converted to C sooner or later, so if you make a start, it surely will be apreciated)  ;D

2. forget the example and code your own application in plain C (I'd do that)

;)

Michael

Link to comment
Share on other sites

I call "application" what is based on the MIOS skeleton (Init(), Timer(), blabla).

Therefore you can achive nearly all you want with a plain C custom application:

You can disable the SRIO driver, setup a timer and scan and set pins of the pic. Besides the specialized de-/multiplexing that's apparently what the SM_example does (please correct me anyone if I am wrong).

But am I right, that you want to use it for reading the state of your C64 Keyboard?

If this is the case, you could just use a DIN module, check the pin states and demultiplex it by code. That sounds a lot easier.

Anyway,

good luck,

Michael

Link to comment
Share on other sites

Sidenote: with the new mkmk.pl script (part of the most recent C wrapper release), it's possible to integrate assembly modules (.asm files) into a C project.

The assembly code must be relocatable (means: it requires a data and code section, absolute addresses should not be specified).

An example can be found in the midi router package, see MAKEFILE.SPEC how to add .asm files, and see int_midi.asm/int_midi.h, how a relocatable module looks like

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi Bill,

as mentioned, I'm not the guy to do ASM, so please don't see my solution as the quickest, best or fastest; but if you can code C it may be the easiest - if that what you get from the keyboard are really just encoded ON/OFF states (I don't know about PS/2 or whatever signals may come out of a keyboard), I would proceed like this:

- add a DIN to your Core

- connect the 8 wires from the Keyboard to 8 DIN pins

- setup a global variable c64matrix[8]; to save space you could create a bitfield.

- now you just have to use the DIN_NotifyToggle() Function,

just place your appropriate handler there. It will notify you whenever a state is switching. Use the global c64matrix to prevent having to check all the other seven pins on notify toggle:

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam {
  // update the matrix
  c64matrix[pin] = value;
  // check what to do
  switch(c64matrix) {
    case 0x00: // e.g. key '0' pressed
      do_that();
      break;
    case 0x01: // e.g. key 'a' pressed
      do_this();
      break;
    default:
      do_nothing();
      break;
   }
}

I think, this might be easy, if the keyboard is really just en-/decoding states;

;)

Regards,

Michael

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