Trouble with large numbers
freq * long, since they are both integers, are calculated as integers.

440*256=112640 - in binary that is 1 1011 1000 0000 0000 and trimmed to 16 bits becomes 1011 1000 0000 0000 which is -18432 and that is where the heart of your problem is.  Unless you explicitly say otherwise the Arduino's compiler does all calculations (except floating point) as 16-bit signed integers.

By casting the values to long it forces the compiler to 'overflow' the 16-bit limit and use a 32-bit limit instead:

long timer = 2000000 / ((long)freq * (long)len);


Another alternative is to define freq and len to be long from the outset instead of int.