Jump to content

J5 DIN in C


John_Swenson
 Share

Recommended Posts

demym,

there's a readme with the j5_io files that explains which functions are available and how to call them:

Available Functions

~~~~~~~~~~~~~~~~~~~

see j5_io.inc for descriptions' date=' and j5_io.h for C declarations

;;  FUNCTION: J5_IO_PinGet

;;  DESCRIPTION: This function returns the state of a single pin at J5

;;  IN:   J5 pin number (0-7)

;;  OUT:  pin value (0 or 1)[/quote']

so, if this function returns void and x is a valid boolean variable, then I expect either 'pinnumber' to be in the wrong range or the setup went wrong.

Best,

Michael

Link to comment
Share on other sites

Ah.

It looks like the C header may be incorrect. Unless I am being stupid (entirely possible) then I think that the following lines in j5_io.h:

extern void J5_IO_Get(void) __wparam;
extern void J5_IO_PinGet(unsigned char pin) __wparam;
Should be:
extern unsigned char J5_IO_Get(void) __wparam;
extern unsigned char J5_IO_PinGet(unsigned char pin) __wparam;

Looking at the assembler source for those two function, the W register contains the result so 'I think' this would fix it.

Try this and if it works I will commit it to svn.

Cheers

Phil

Link to comment
Share on other sites

Thanks Phil.

So, i've changed the code in J5_IO.h:

unsigned char J5_IO_PinGet(unsigned char pin) __wparam;

Now the function works like expected... But....

I'm trying to poll into the Tick function, and check if pin 0 (for example) has changed value....

I also include an image of the breadboard; the voltage connectors are arriving from J5 supply on core, and the top cable is getting first 4 data pins from J5:

immag061.jpg

The problem is that it seems to change value even if i do not press the button.. I'm only trying pin 0 of J5, the button is on a breadboard; i have a 10k resistor between +5V and the pin 0 of J5, and the button is connecting to ground when pushing; voltages corresponds; i have 0,30V when button is not pushed, and 0V when button is pushed.

This is my code:

unsigned char lastvalore;  //this initializes to 0 into the Init function

void Tick(void) __wparam

{

    valore=J5_IO_PinGet(0);

    if (valore!=lastvalore)

    {

      //i use midi messages to check response, as i had some problems with 2 lcds (and ordered a third one....)

      MIOS_MIDI_TxBufferPut(192);

      MIOS_MIDI_TxBufferPut(valore);

      lastvalore=valore;

    } 

}

But this code loops the midi message even if i don't push the button (and MIOSStudio hangs....)..

What am i doing wrong ?

Sorry for the long problem and misunderstanding

Thx

Link to comment
Share on other sites

The breadboard is connected exactly as your ascii art :-)

i have a 10k resistor between 5V and J5-0, and switch cuts in front of it (the resistor) and goes to ground....

But even if i eliminate the switch , i still never have 5V on pin 0; isn't this logical, as i have a voltage fall due to the resistor ? That's a point that i can't keep understanding...... (but i am an electronics novice, and i'm surely missing something)

Obviously it is not suggested to take off the resistor, right ?

Link to comment
Share on other sites

The breadboard is connected exactly as your ascii art :-)

Ahh okay it seems we tend to align our switches differently on breadboard (rotated 90degrees) , But even then in your pic it is not connected to the jumper at the top... well it's connected to the jumper but you don't have anything plugged into that pin (the far right pin on the jumper)

But even if i eliminate the switch , i still never have 5V on pin 0; isn't this logical

Obviously it is not suggested to take off the resistor, right ?

correct, do NOT remove that resistor or you will fry things (short it)

If you've got 5V on one side of the resistor and 0V on the other, the resistor is dead (that'd be a first! heheh)

If you've got 5V on one side of the resistor and 5V on the other, and 0V on the PIC pin, your wiring between the resistor and PIC is dodgy.

Maybe you really do have that switch inserted wrong?

Edit: actually that makes sense with your 0.3V reading because the 5V-resistor-gnd would be hardwired always, then that would be connected to the PIC pin when you switch on, and it should still read near 0, but there would be a small leakage due to the resistance... Edit2: only, that still doesn't make sense because in your image the PIC just isn't connected to anything at all...

Link to comment
Share on other sites

UPDATE !

I had some problem on pin0 (looking at the core board it seems like a dry soldering)...

works on other 3  pins !!

My big ThankYou to all you helpful people !

(but i don't think these will be the last questions.....my next step is to successfully integrate an LCD... i'll let you know :-))

Thanks, have a nice time !

Link to comment
Share on other sites

Sweet!

Phil's right, the LCD is likely to be a bit easier ;)

I guess there is a lesson here, that if you don't get the reading you expect when you test with a meter, test at as many points as possible along the 'path' of the signal, to see if you can locate the problem.

In this example, if you test the PIC pin and expect 5V and get 0V, then test at the bottom of the socket, at the header, on the wires at either end of the cable, on the breadboard, at the switch, at the other side of the switch, on the power rail, etc etc... It sounds like a lot, but really it's only tap, tap, tap, ... and takes like 5 seconds... Definitely worth it when you consider the alternative!

Link to comment
Share on other sites

  • 4 years later...

Hi, i know, thats an old thread but I searching infos. Correct me when I am wrong:

 

Demym wrote:

The DOUT part of the circuit works (i've connected 4 leds, with a 470 ohm resistor, and leds switch on-off correctly, based on my midi commands to the core).

 

http://www.ucapps.de/mios/j5_dout.pdf --> shows 220 Ohm ! (so demym, your info of 470 is wrong...)

 

Greets,

rio

Edited by Rio
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...
 Share

×
×
  • Create New...