P0340 is a flatline code for the cam sensor, so if it isn't the sensor itself, it has to be either wiring or connector pin-fits. The latter are a common cause of come-and-go problems on older cars. You can find the ECM pin reference and wiring diagram here starting on page EC-443:
https://www.nicoclub.com/service-manual ... 1%2FEC.pdf
If you don't want to buy a pin-fit tool, a piece of 0.025" music wire or a safety pin with 0.024"~0.026" diameter are good substitutes.