Spanish riot police have clashed with a crowd of protesters as they tried to stop a referendum on Catalonian independence from going ahead.