Jump to content

CORE_LPC17 J5a/b


savethecheerleader
 Share

Recommended Posts

I'm in the process of building my first ever CORE_LPC17 module. The controller I'm making only has four pots, four buttons, four LEDs, two encoders, and an LCD.

What I'm trying to understand is how I can use J5a/b.

I was reading on the LPC17 project page and it talks about using J5a/b to hook up analog sources (like my four pots). It also talks about using the J5a/b pins as digital ins or outs.

What I'd like to do is hook up my four pots to J5a and then use J5b as a digital out for my four LEDs. Is this possible? If so, how do I specify the function of those pins?

Link to comment
Share on other sites

Hi.

In mios32_config.h you can enable J5a as analogue input:


#define MIOS32_AIN_CHANNEL_MASK_0x000f

whenever the analogue input changes (pot moved) your APP_AIN_NotifyChange(u32 pin, u32 pin_value) function will be called. You also need to initialise the J5b pins as output using the MIOS32_BOARD_J5_PinInit() function:

	int pin

	// Init J5B as output

	for (pin=4;pin<8;++pin)

		MIOS32_BOARD_J5_PinInit(pin,MIOS32_BOARD_PIN_MODE_OUTPUT_PP);

You can then use the MIOS32_BOARD_J5_PinSet(pin,value) function to turn the LED off and on.

If you need more information, look at the tutorials: MIOS32 (for STM32 and LPC17) specifically the J5 Outputs and Scanning 12 analog pots ones!

Cheers

Phil

Edited by philetaylor
Link to comment
Share on other sites

Sweet. Thank you, Phil! I will check this stuff out.

I just had another question come up that I think you might be able to help answer too. I'm thinking about using J10 to connect my two encoders and four buttons (ideally, I'd like to not have to use a DIN or DOUT module if possible). Do I have to activate J10 at all?

I saw on the LPC17 project page something about accessing it via MIOS32_BOARD_J10, but when I went to the MIOS32_BOARD functions list, I didn't see anything about J10.

I did some more Googling. Would this work to enable J10?

int pin;

for(pin=0; pin<8; ++pin)

    MIOS32_BOARD_J10_PinInit(pin, MIOS32_BOARD_PIN_MODE_INPUT_PU);

Also, do I insert these code snippets into mios32_config.h or a different file?

Sorry if these are dumb questions. I'm a web programmer and have never worked with C.

Edited by savethecheerleader
Link to comment
Share on other sites

Yes, you can also connect encoders to J10.

The MIOS32 documentation is currently generated for STM32 where this port is not available, but if you look into the source code you will find them: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fmios32%2FLPC17xx%2Fmios32_board.c

Encoder related informations are available in Tutorial #015b: http://www.ucapps.de/mios32_c.html

Just replace J5 by J10 -> done! :)

Best Regards, Thorsten.

Link to comment
Share on other sites

Great! I checked out the source code, and I see what you are talking about.

I'm still just a little confused. I just want to make sure I understand correctly... am I understanding correctly that unlike J5a/b, I do not have to activate or initialize the J10 pins? In other words, can I start hooking stuff up to J10, and then I follow the Tutorial #015b to define the number of encoders that I have hooked up?

Also, is there any type of tutorial or procedure that I need to know about when it comes to hooking up momentary buttons to J10? I'm assuming they are simpler than the encoders and wouldn't require any type of coding, but I just want to make sure.

Many, many thanks.

Link to comment
Share on other sites

J10 pins are configured as inputs by default.

Therefore I'm a bit biased: no, you don't have to initialize the pins (again), on the other hand it's good programming practice to initialize IO pins explicitly for the intended mode.

Why do you think that it would be better to skip the initialization?

Buttons connected to J10: take tutorial #005 as an example and replace J5 by J10

Btw.: I gave you access to the programmers lounge where you will find more background informations.

Best Regards, Thorsten.

Link to comment
Share on other sites

Thank you, Thorsten. You've been very helpful, and I'm very grateful.

I wasn't trying to imply that I thought it better to skip the initialization. It's good for me to know that it is good practice to initialize the pins for the intended mode. I am honestly just very confused as this is an entirely new world to me, so I'm trying to learn as much as I can. :) Thank you again. I am learning a lot.

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