Using ic_test sample program with BL2600

Hi All

I have a BL2600 and am trying to read in the pulse width of a square wave.

The square wave is generated by a wind speed sensor, and the frequency of the square wave changes proportionally with wind speed. Therefore simply reading the pulse width of half a cycle will result in a number that can be related to wind speed.

I found the following ic_test.c sample program in the …/samples/rabbit3000 directory, but the BL2600 schematic shows PG0 and PG1 not accesable in the same context as the example. (In another interupt sample program …/samples/interupts/extint_3000.c PE0 and PE1 are used, but again these are not acessable on the BL2600)

So the questions are, what is the syntax of the arguments for the WrPortI function and, how do I get a signal to this function using the BL2600?

clipped from …/samples/rabbit3000/ic_test.c
WrPortI(ICS1R, NULL, 0xCC); //PG1 is pulse capture pin for channel 1

clips rom …samples/interupts/extint.c
WrPortI(PEDDR, &PEDDRShadow, 0x00); // set port E as all inputs
WrPortI(I0CR, &I0CRShadow, 0x09); // enable external INT0 on PE0, rising edge, priority 1

WrPortI(I1CR, &I1CRShadow, 0x09); // enable external INT1 on PE1, rising edge, priority 1

Z-World, 2002

This program is used with RCM3000 series controllers
with prototyping boards.

This program demonstrates a simple application of input
capture peripheral.  It measures the duration of a low pulse
on switch S2 (PG1) and displays to STDIO.  Port G bit 1 is
channel 1 pulse capture pin.

Note:  Interrupts are not used in the demo.

1. Compile and run this program.
2. Press and release switch S2 on the proto-board.
3. Observe the amount of time you hold S2 down in STDIO.

#class auto

void main()
char capture_status;
unsigned long pulse_width;

WrPortI(ICS1R, NULL, 0xCC); 	//PG1 is pulse capture pin for channel 1

//use freq_divider for input capture prescaler
//(freq_divider-1) runs at 19200*16Hz, multiply by 4 for better range
WrPortI(TAT8R, NULL, freq_divider*4 - 1); //(TA8 prescaler)
WrPortI(ICCSR, NULL, 0x0c); 					//zero out counters
WrPortI(ICCR, NULL, 0x00); 					//no interrupts

//run counter start to stop
//start is falling edge, stop is rising edge
//latch counter on stop
WrPortI(ICT1R, NULL, 0x59);

pulse_width = 0;

	//listen for capture states
	capture_status = RdPortI(ICCSR);
	if(capture_status & 0x10)
		//channel 1 stop occured
		//read capture value, LSB first
		pulse_width += RdPortI(ICL1R);
		pulse_width += RdPortI(ICM1R)*256;

		//76.8 = 19200*16*1000/4 (see TA8 setting above)
		printf("channel 1 pulse: %.1fms

", (float)pulse_width/38.4);
pulse_width = 0;
WrPortI(ICCSR, NULL, 0x04); //zero out counter
else if(capture_status & 0x04)
printf("Input capture counter rolled over.
pulse_width += 0x10000;


That’s correct. Some interrupts or ports are not accesible on the BL2600 board. I came accross that at well and would like to advise you to only look at Samples\BL2600 directory. To read an input use digIn() and to write use digOut().