Hardware slow pulse counting with Uno R4 Minima

Hi,
I am counting 5 V pulses, 1 to 10 pulses per second, varying length and spacing, in Uno R3 per page 682 of the Arduino Cookbook:
const int hardwareCounter=5 //input pin fixed to integral timer
void setup()
{
pinMode(buttonOn, INPUT_PULLUP);
TCCR1A=0;
}
void loop()
{
//Start the counting
bitSet(TCCR1B, CS12);//Counter clock source is external pin 5
bitSet(TCCR1B, CS11; //Clock on rising edge
delay(samplePeriod); // Sample period set to (4000), 4 seconds
TCCR1B=0; //Stop the counting
count=TCNT1; //Counter output
TCNT1=0; Reset the hardware counter

The counter output is then used in my logic as follows:
if((b=!digitalRead(buttonOn)||count>4))
{
etc.
This works perfectly in the Uno R3, which I happened to "fry" and ordered an R4...
Can anyone help with doing this in the R4? Thanks

Uno R4 is not an "advanced version" of the Uno R3, they are a completely different microcontrollers.

You code used a R3-specific hardware registers, it is not compatible with R4. To port the code to R4, it should be written from scratch.

Thank you b707. Yes, I understand. Could someone help me out with that? Erik