After a lot of research for a couple weeks. The problem was indeed the camshaft sensors, but need to replace all of them. That includes the Bank 1, Bank 2, and the crankshaft sensors as well. Even though only Bank 1 was mentioned for that error code of P0340. Then if you get the P0021 error afterward, try to clean the value, oil residue probably got into it. This was the result of my Nissan Quest 2005, stalled after 30 mins or so running, and when try to start again, it kept on cranking for a long time before getting a hit to start. Very dangerous if you let woman or daughter driving it and stalled in the middle of the road or highway they wouldn’t know what to do, but actually you can put the shift into Neutral position and then start the engine again, it will crank long time, but it will start and all the lights will come on, just drive home or to automotive shop.
Bulletins announcements from Nissan Manufacturer. http://helpforcars.net/tsb/tsb.php?tsb_id=203269&tsb_code=p0340&tsb_make=nissan
Where are the CMD sensor, Camshaft, Crankshaft sensors located on a 2005 Nissan Quest? http://engine-codes.com/qa/3449/where-camshaft-position-sensor-circuit-located-nissan-quest