What you described sounds like an issue with the crankshaft position sensor. It can fail and not set a code. Take a look through this link and let me know if it seems to mirror what you experience.
What I suggest is this. When it refuses to start, either check for ignition spark to the plugs, or if you have a live data scan tool, check for an RPM signal when the engine is cranking. When these sensors start to fail, oftentimes they are affected by heat. Once they cool, they work again.
Here is a link that explains how to test ignition spark:
We want to be sure if the sensor is bad before trying to replace it. It isn't an easy one to replace simply because of its location. If you question it, here are the diagnostics for testing the sensor and system.
2004 Hyundai XG 350 V6-3.5L
Component Tests and General Diagnostics
Vehicle Powertrain Management Sensors and Switches - Powertrain Management Sensors and Switches - Computers and Control Systems Crankshaft Position Sensor Testing and Inspection Component Tests and General Diagnostics
COMPONENT TESTS AND GENERAL DIAGNOSTICS
CRANKSHAFT POSITION SENSOR
The crankshaft position sensor is a Hall-effect sensor that senses the crank angle (piston position) of each cylinder and converts it into a pulse signal. Based on the input signal, the PCM computes the engine speed and controls the fuel injection timing and ignition timing.
1. If unexpected shocks are felt during driving or the engine stalls suddenly, shake the crankshaft position sensor harness. It this causes the engine to stall, check for poor sensor connector contact.
2. If the tachometer reads 0 rpm when the engine is cranked, check for faulty crank angle sensor, broken timing belt or ignition system problems.
3. If the engine can be run at idle even it the crank angle sensor reading is out of specification, check the following:
- Faulty engine coolant temperature sensor
- Faulty idle speed control motor
- Poorly adjusted reference idle speed
4. The engine will run without a crank angle sensor signal, but will not start. Once the sensor detects TDC, the data is stored until the next re-start.
Harness Inspection Procedures
Let me know if this helps or if you have other questions.
Images (Click to make bigger)
Tuesday, November 3rd, 2020 AT 6:13 PM