"The Twilight Zone" (Eighties revival of TV anthology series)
"A Message from Charity" (episode)
Excerpt from Wikipedia:
Peter Wood is a teenager sick with a fever that puts him in telepathic contact with Charity Payne, a Puritan girl from Colonial America (specifically 1700), who also has the same type of fever. The two share realistic thought-visions of each other's worlds, and Charity has a glimpse of the world in the year 1985. The teenagers discover they can communicate, and they form a true friendship.
When Charity is discovered (when she tries to humble a know-it-all neighbor girl), she is branded a witch for her knowledge of future events. Now her friend from the future must help her escape the clutches of her villagers and prove she is not a witch before she is tried and executed.