BIBLIOTECA MAX6675

Amigos, consegui no site da Mikroeletronika a biblioteca para utilização do CI MAX6675 com PIC's em um projeto de leitura de um sensor termopar tipo K ligado a este componente que se comunica com o PIC via serial (protocolo SPI). O que eu estou tentando fazer, é obter a leitura do termopar em questão e mostrar a leitura em 3 displays de leds de 7 segmentos. A parte referente aos displays e seu acionamento está funcionando perfeitamente. O que acontece é que a biblioteca parece conter algum erro ou falha por parte do autor, pois os números apresentados nos displays são totalmente aleatórios e sem significado nenhum. Segue o código fonte da biblioteca para você conferirem. Será que alguma coisa poderia ser feita? Já fiz várias alterações seguindo sugestões do Sr. Dusan da Mikroe, mas nada resolveu o problema. Alguém teria alguma sugestão neste caso? Segue a biblioteca:
cpp code
cpp code
//============================================================================
// Library: MAX6675_Library.
// Author : Arezki YOUYOU
// Date:06/11/2015
// Microcontrollers : PIC12F, PIC16F, PIC18F
/*******************MAX6675********************************************/
//The MAX6675 library use the MAX6675 circuit to read the thermocouple and transform the
//temperature data in Celsius or Fahrenheit.
//============================================================================
// Contact me:
// e-mail: arezkiyouyou@gmail.com
//============================
extern sfr sbit MAX6675_SCK_Dir;
extern sfr sbit MAX6675_CS_Dir;
extern sfr sbit MAX6675_MISO_Dir;
extern sfr sbit MAX6675_CS;
extern sfr sbit MAX6675_MISO;
extern sfr sbit MAX6675_SCK;
void MAX6675_Init() {
MAX6675_SCK_Dir=0;
MAX6675_CS_Dir=0;
MAX6675_MISO_Dir=1;
MAX6675_CS=1;
}
char MAX6675_Read(){
int j=0;
char s=0;
for(j=7;j>0;j--){
MAX6675_SCK=0;
Delay_ms(1);
if(MAX6675_MISO){
s |= (1 << j);
}
MAX6675_SCK=1;
Delay_ms(1);
}
return s;
}
double MAX6675_Read_Celsius(){
unsigned int temp;
MAX6675_CS=0;
Delay_ms(1);
temp=MAX6675_Read();
temp<<=8;
temp|=MAX6675_Read();
MAX6675_CS=1;
if(temp& 0x04){
return -222;
}
temp>>=3;
return ((double)temp*0.25);
}
}