Skip to content

General code issues thread #108

@TaraHoleInIt

Description

@TaraHoleInIt

I'll start the first one:

In my attempt to debug WaitForRisingEdge by passing in a debug LED I now receive the following error message:

^^^^^^^^^^^^^^^^^^^ incorrect input parameters in call to algorithm 'WaitForRisingEdge', last correct match was parameter 'Signal'

I've checked the documentation and examples a few times, and its not immediately obvious why this is coming up.

$$Period = 1 / Frequency;
$$NSPerClock = 1000000000 * Period;
$$ClocksPerMS = math.floor( 1000000 / NSPerClock );

algorithm Debounce( input uint1 Source, output uint1 Dest ) <autorun> {
	uint24 Clocks = 0;
	uint8 Bitmap = 0;

	while ( 1 ) {
		Clocks = Clocks + 1;

		if ( Clocks == $ClocksPerMS$ ) {
			Bitmap = ( Bitmap << 1 ) | Source;
			Clocks = 0;
		}

		// If all the bits are set then the button should have finished bouncing
		// and the output should be reliable.
		Dest = ( Bitmap == 8hff ) ? 1 : 0;
	}
}

subroutine WaitForRisingEdge( input uint1 Signal, output uint1 Debug ) {
	uint1 Last = 0;

	Debug = 1;

	while ( 1 ) {
		if ( Last == 0 && Signal == 1 ) {
			break;
		}

		Last = Signal;
	}

	Debug = 0;
}

algorithm main( output uint$NUM_LEDS$ leds, output uint$NUM_GPIO_OUT$ gp, input uint$NUM_GPIO_IN$ gn ) {
	uint1 FilteredButton = 0;
	uint1 Button = 0;
	uint1 State = 0;

	Debounce Btn(
		Source <: Button,
		Dest :> FilteredButton
	);

	Button := gn[ 10,1 ];
	leds[ 0,1 ] := State;

	while ( 1 ) {
		// Error
		// ^^^^^^^^^^^^^^^^^^^ incorrect input parameters in call to algorithm 'WaitForRisingEdge', last correct match was parameter 'Signal'
		( ) <- WaitForRisingEdge <- ( FilteredButton, LED );
		State = ~State;
	}
}
```

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions