stryd_one Posted February 24, 2009 Report Share Posted February 24, 2009 If you can handle a bit of ASM, there's the example app there which demonstrates best use... You put the Get in the user timer handler, and just save the values to a variable, then read them back and manipulate them in the user tick. Quote Link to comment Share on other sites More sharing options...
demym Posted February 25, 2009 Report Share Posted February 25, 2009 I'm trying to use the J5_IO_PinGet function... but i've noticed that it returns void, so cannot be used this way:x=J5_IO_Pinget(pinnumber);Where do i store the value returned by this function ? Thanks Quote Link to comment Share on other sites More sharing options...
audiocommander Posted February 25, 2009 Report Share Posted February 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
philetaylor Posted February 25, 2009 Report Share Posted February 25, 2009 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.CheersPhil Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 25, 2009 Report Share Posted February 25, 2009 Yep totally. Actually it will probably behave anyway because of the wparam flag (SDCC peculiarity) but it's definitely best to have it like you said so the compiler is happy... Quote Link to comment Share on other sites More sharing options...
audiocommander Posted February 25, 2009 Report Share Posted February 25, 2009 yes :-)it's not correct it the current svn either.Best,Michael Quote Link to comment Share on other sites More sharing options...
philetaylor Posted February 25, 2009 Report Share Posted February 25, 2009 It is now :)Phil Quote Link to comment Share on other sites More sharing options...
demym Posted February 25, 2009 Report Share Posted February 25, 2009 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: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 functionvoid 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 misunderstandingThx Quote Link to comment Share on other sites More sharing options...
philetaylor Posted February 25, 2009 Report Share Posted February 25, 2009 The only thing that springs to mind is looking at your breadboard, you have left pins 1-7 'floating'. It is always a good idea to tie them to ground if they aren't being used as they will be generating spurious values.....CheersPhil Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 25, 2009 Report Share Posted February 25, 2009 i have 0,30V when button is not pushed, and 0V when button is pushed.That ain't right. Should be 5V when not pushed, 0V when pushed. Your breadboard doesn't look like the schem to me.... Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 25, 2009 Report Share Posted February 25, 2009 j5:0---+--/\/\/----5V | \--switch---GND ASCII art... can't beat it.Well, you can, but it's still cool :) Quote Link to comment Share on other sites More sharing options...
demym Posted February 25, 2009 Report Share Posted February 25, 2009 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 ? Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 25, 2009 Report Share Posted February 25, 2009 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 logicalObviously 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... Quote Link to comment Share on other sites More sharing options...
demym Posted February 25, 2009 Report Share Posted February 25, 2009 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 ! Quote Link to comment Share on other sites More sharing options...
philetaylor Posted February 25, 2009 Report Share Posted February 25, 2009 That's great news :)Compared to getting J5_IO working with C, the LCD should be a walk in the park as the MIOS LCD support is very comprehensive and has been thoroughly tested in literally hundreds of units :)CheersPhil Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 25, 2009 Report Share Posted February 25, 2009 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! Quote Link to comment Share on other sites More sharing options...
Rio Posted April 16, 2013 Report Share Posted April 16, 2013 (edited) 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 April 16, 2013 by Rio Quote Link to comment Share on other sites More sharing options...
ilmenator Posted April 16, 2013 Report Share Posted April 16, 2013 The correct resistors' value depends on the LED and the brightness you want to achieve. Whether one uses 220 Ohm or 470 Ohm does not affect functionality in this context! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.