The driver of a Spanish train that crashed killing 79 people said he was talking by phone to the train’s on-board ticket inspector moments before the accident but hung up just before the train left the tracks, a court said Wednesday.

Train driver Francisco Jose Garzon Amo went to the court on his own initiative and told the judge he received a call from the ticket inspector about which platform to take on arriving at a station, a court statement said.

Garzon told the judge, who is trying to establish whether human error or a technical failure caused the country’s worst rail accident in decades, that he hung up “seconds before” the train hurtled off the track.

Garzon’s testimony cleared up the mystery of who had been on the phone with him as he approached a risky curve just outside Santiago de Compostela in northwestern Spain on July 24.

However, it left a contradiction because the court said “black box” data recorders examined by investigators Tuesday showed Garzon was on the phone at the time of the derailment — though they didn’t know who was speaking to him beyond the fact it was a company employee.

Nor did Wednesday’s statement on Garzon’s unanticipated appearance before the investigating judge in Santiago de Compostela mention whether the driver was questioned about other preliminary findings from the black boxes, including the crucial question of the train’s speed, that were announced the previous day.

The train had been going as fast as 119 mph shortly before the derailment, and the driver activated the brakes “seconds before the crash,” according to those findings. The speed limit on the section of track where the crash happened was 50 mph.

A court spokeswoman was unable to give any further details regarding the driver’s latest appearance. She confirmed, however, that the inspector had survived the crash and been identified.

Garzon, the driver, was provisionally charged Sunday with multiple counts of negligent homicide after his first testimony before the judge. He was not sent to jail or required to post bail because none of the parties involved felt there was a risk of him fleeing or attempting to destroy evidence, according to a court statement.

He was apparently consulting a paper document in his cabin while on the phone with his colleague from national rail company Renfe when the train hurtled off the tracks, according to the preliminary findings. No technical failure has been found so far.

Some 61 people injured in the disaster are still hospitalized, 13 of them in critical condition.

The investigating judge has asked for more information from a variety of sources, the court said.

He has asked Renfe for details of the driver’s routine drug tests, results from his psychological tests, illnesses, experience and working hours, as well as information about the track, speed limits and work procedures of train staff.

He also has asked for phone company records pertaining to the driver’s cellphone.

Phone contact between drivers and control centers is not unusual but not recommended if it poses a risk, a Renfe spokeswoman said Wednesday. She said a driver is under no obligation to answer an incoming call if he deems it best not to.

The driver has access to two phones: one fixed in the driver’s cabin and the other a cellphone. She said there is no contact by computer in the form of emails or messages.

The Spanish rail company has said the brakes should have been applied 2.5 miles before the train hit the curve.

The investigation could last several more weeks.