RCM4010: Getting started

Hi,

I’m using an RCM4010 module mounted on the prototyping board which was included with the RCM4000 development kit; I am comfortable with using dynamic C as I am an experienced programmer, but I am somewhat less experienced with the electronics / hardware side of things, so I am stuck as to what the prototyping board’s many terminals are for, and how to properly connect devices to the parallel ports, etc. to be interfaced with the processor.

I have run a few simple test programs using the module and prototyping board’s LEDs via internal parallel ports, such as making the LEDs produce morse code messages, etc., but I am unsure about how to connect external devices to these ports, and don’t feel comfortable messing with the board without an expert opinion :o

Anyway, long story short I’d like to connect a couple of LEDs to the prototyping board and control them via a program, and once I know how to do that correctly I shouldn’t have any problem progressing to more complicated devices.

Thanks in advance for any help :smiley:

It’s easy, but on the other hand, it’s not…

The main thing you need to be concerned with is that the voltage and current levels are compatible. For instance, you may want to run the LED at 10ma (and LEDs are really current devices, so what you learn interfacing an LED to the processor may not apply all that well when you then go and try to interface something like a DAC), but the device you’re driving it from might only be able to supply 8ma (and watch out, because there are devices that can sink and source different amounts of current). So that’s not going to work (for very long at least). So in this case you need a buffer. There are chips you can use for that, or you could use a transistor. Or you could find an LED that would be happy running on 5ma…

You typically connect the anode of the LED to the positive power supply (say +3.3V), then drive the cathode low from your parallel port output to turn it on. You need a current-limiting resitor in series with the LED. LEDs are kind of funny in that you’ll notice that the different colors have different voltage drops, so you have to figure out what resistance you need for each kind of LED you’re using. Let’s take a typical red LED that has a forward voltage drop of 2.1V, and we want to limit it to 5ma. That means the series resistor has to drop 1.2V @ 5ma (this assumes that the output actually pulls the voltage down to 0V, which it won’t but it’s close enough for this purpose). Using Ohm’s Law, we need a 240 ohm resistor, and that happens to be a standard value…

Now, if you’d said you wanted to start by interfacing an LCD character display, things would actually be a little easier in the voltage and current department, since you can find one that is directly compatible with the signal levels you have. You now have timing considerations to take into account, though…

I would suggest you buy a copy of The Art of Electronics by Horowitz & Hill to get a better understanding of the hardware side of things.

Don’t worry, by less experienced with electronics I mean I look at the enormously complex-looking prototyping board and go :eek:, not that I don’t understand how to use ohm’s law to calculate the resistor value required for the LED.

As it happens, I have an LCD character display salvaged from a calculator which I would like to try to interface with the board at some point, but looking at the proximity and sheer number of its contacts, it seems extremely unlikely that this would be easier to interface than an LED would.

You mentioned that the anode should be connected to a 3.3V power supply, does this mean that the devices connected to the board should have their own separate power supply?

No, the board should be able to supply some excess current over what the processor needs. Don’t know if your board is the same as the one I have for the RCM4100, but mine has +5V as well as +3.3V available…

I only go :eek: when I try to solder surface mount devices. Oh, and if you don’t have a data sheet for your LCD display then that makes things much harder. I was thinking something like this:
http://www.lcd-module.com/eng/pdf/doma/dip204-4e.pdf

Ah yes, that device does look rather more friendly. The device I’m referring to has approximately 100 contacts of width 0.2mm with 0.2mm gaps inbetween… I’m fairly certain the only way I’ll be able to interface such a device is to use a board designed to interface with the device itself. Such as the circuit board of the calculator itself. As it happens, the majority of the calculator board’s surface was taken up by the pathways which dealt with the display.

Anyway, back to the board: I appear to have a row of 14 contacts on the prototyping board with a marking indicating 3.3V, and another row of 5V terminals. So I simply need to connect the anode to one of the 3.3V ports and the other end of the external circuit to the appropriate contact for the parallel port and bit I wish to interface with, correct?

For example, if I connect the anode of the LED to one of the 3.3V ports and the cathode to PA1 (ignoring any resistors which may be appropriate for now), I should then be able to turn the LED on with a dynamic C function call such as


BitWrPortE(PADR,&PADRShadow,0,1);

Is that correct?

That would be correct for PE1, not PA1.

Whoops, copied and pasted the line from my morse code program and forgot to change the PEDR and &PEDRShadow references. Right, I’ll give that a try then. And hope it doesn’t blow up.

By the way, where might I find out what the maximum current through the parallel ports actually is? The 8mA you suggested seems extremely low…

The 8ma figure came from the Specifications section of the Rabbit 4000 Microprocessor User Manual. Also appears in the RabbitCore RCM4000 User’s Manual (Table A-4).

It appears I’ll have to use a transistor and secondary power source then. The type of LED I am planning on testing is the 5mm variety and usually seems to operate best at around 50-100mA.

Thanks for the help sgt, I’ll be back if I run into any problems :stuck_out_tongue:

Perhaps I’m just missing something in dynamic C now, but I’ve connected an LED to parallel port A bit 6 (I just picked a convenient port where I could safely balance the LED in the holes without having to solder it) and changed a couple of my test programs to use the flash the LED I added as well as the ones on the prototyping board and module.

But instead of flashing the LED, the LED comes on when the program starts, and stays on throughout its execution. Any idea why? Here’s the code I’m using as a test:


typedef enum {false,true} boolean;

#define on false
#define off true

#define PORT_A PADR
#define PORT_B PBDR
#define PORT_E PEDR

#define PORT_A_SHADOW &PADRShadow
#define PORT_B_SHADOW &PBDRShadow
#define PORT_E_SHADOW &PEDRShadow

#define DS2_BIT 2
#define DS3_BIT 3
#define GREEN_LED_BIT 5
#define YELLOW_LED_BIT 7
#define CUSTOM_LED_BIT 6

void main()
 {
 brdInit();

 while(true)
  {
  costate
   {
   BitWrPortI(PORT_B,PORT_B_SHADOW,on,DS2_BIT);
   BitWrPortI(PORT_B,PORT_B_SHADOW,off,DS3_BIT);
   waitfor(DelayMs(50));
   
   BitWrPortE(PORT_A,PORT_A_SHADOW,on,CUSTOM_LED_BIT);
   BitWrPortI(PORT_B,PORT_B_SHADOW,off,DS2_BIT);
   waitfor(DelayMs(50));

   BitWrPortI(PORT_B,PORT_B_SHADOW,on,DS3_BIT);
   BitWrPortE(PORT_A,PORT_A_SHADOW,off,CUSTOM_LED_BIT);
   waitfor(DelayMs(50));
   }
  costate
   {
   BitWrPortI(PORT_E,PORT_E_SHADOW,on,GREEN_LED_BIT);
   BitWrPortI(PORT_E,PORT_E_SHADOW,off,YELLOW_LED_BIT);
   waitfor(DelayMs(500));

   BitWrPortI(PORT_E,PORT_E_SHADOW,off,GREEN_LED_BIT);
   BitWrPortI(PORT_E,PORT_E_SHADOW,on,YELLOW_LED_BIT);
   waitfor(DelayMs(500));
   }
  }
 }