DUBAI, United Arab Emiratees (AP) _ An Iranian warship today opened fire with machine guns on a helicopter carrying an NBC television crew in the southern Persian Gulf, shipping sources reported.

No one was hurt and there was no damage to the aircraft.

The warship had issued a radio warning, but the NBC helicopter was not tuned to that frequency. The vessel apparently confused the helicopter with another that was flying in the same area.

The helicopter apparently confused the Iranian vessel with a U.S. warship in the area.

''Civilian helicopter, this is an Iranian warship,'' the Iranian frigate blared over an emergency radio channel.

''Clear my area. This is your last warning,'' one of its personnel said. Then a burst of machine gun fire was heard.

The helicopter carrying the NBC crew had been conversing with an unidentified U.S. warship several miles to the north, about 30 miles off the southern gulf port of Dubai.

Grant Witham, the pilot of the single-engine Bell 206 Jet Ranger helicopter, said the incident was due to the confusion arising when the two helicopters were flying in the same area at the same time.

The other helicopter was flying with a crew from the CBS broadcast network, who were monitoring the channel on which the Iranian warning came.

Witham was holding a radio conversation with the American warship about 15 miles north, asking for permission to film the vessel. When the ship accepted, he began flying low toward it.

Later, he asked the American warship to confirm his range, and it told him he was seven miles away, he related.

But he saw he was only two miles away from the ship he thought he was talking to, and realized that something was wrong.

The ship below him was flying the Iranian flag. Steve O'Neal, the NBC cameraman, identified it as a British-made Type 22 frigate.

The American frigate apparently had its eye on the closer CBS helicopter while talking by radio to the NBC team, while the Iranians were warning away the closer NBC helicopter while NBC was hooked by radio to the Americans.

The 30-year-old Witham, oblivious to the Iranian warnings, flew parallel to the Iranian frigate five-to-six feet above water for seven minutes before the craft was fired at.

The CBS helicopter, which could hear the Iranian warnings, succeeded in alerting the NBC helicopter by radio as to what was going on.

Witham said that when the shooting started ''I went low over the water, zig-zagged and veered left,'' back to Dubai.

''As it turned out to be, everybody believed everybody was everybody else. It was too amazing.''

Scores of reporters have flocked to Dubai, a major gulf port, to cover the escalation of tension in the waterway resulting from the Iran-Iraq war.

They often charter helicopters and boats to film U.S. Navy warships escorting reflagged Kuwaiti tankers, an operation that began in July as an attempt to protect the vessels from Iranian attacks.