Charm photoproduction and fragmentation at HERA