This is going to get messy!
Suggest a first port of call should be the program "EasyGPS" - EasyGPS - FREE GPS Software for your Garmin, Magellan, or Lowrance GPS
The Garmin GPSMAP 640 is on the list of GPS in that program.
Make a GPX in OpenCPN. Open it in in EasyGPS and send it to the Garmin.
This will prove the basic transfer of routes is working correctly.
Then try the suggestions from this forum and the manual.
I tried a lot of things but I could only directly transfer waypoints from O.
The program https://www.gpsbabel.org/
is OpenSource and, like EasyGPS, transfers routes and waypoints.
In the end I wrote the OpenCPN plugin oBabel. This automates the use of "gpsbabel" and means that I can directly transfer a route
created with OpenCPN to my Garmin, with the plugin, without leaving O.
The connection was a Garmin NMEA 0183
cable via serial plug
to a USB/Serial adapter. Not all USB/Serial adapters are created the same. I think Prolific drivers used to have problems with Windows 8.1/10. Not sure if this is still the case.