I see you are using USB loader and are stuck with 48mHz. Perhaps this is too fast for TM1640. Have you got a slower PIC to try with.
My code does work at 4mHz.
Have you got the datasheet for TM1640?
Phil