Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F25K20 - SPI work on picc18 STD, not work on PRO version ! Why???

Status
Not open for further replies.

ognjan

Newbie level 5
Joined
Nov 21, 2004
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
73

This is a small example that works perfectly normal when compiled with PICC-18 STD v9.52, but it does not work when compiled with PICC-18 PRO v9.80!?

PIC18F25K20 @ 4MHz write data to CC1101 register


#include <htc.h>

void SPI_TR_Done(char data)
{
SSPBUF = data;
while(!SSPIF);
SSPIF = 0; // Reset SSPIF flag
}

void SPI_Write(char adr, char data)
{
RC2=0; // chip select
while (SDI);
SPI_TR_Done(adr);
SPI_TR_Done(data);
RC2=1;
}

void main(void)
{
char x;
CM1CON0 = 0;
CM2CON0 = 0;
ANSEL = 0;
ANSELH = 0;
ADCON0 = 0;
ADCON1 = 0;
RBPU = 0;
PORTA = PORTB = PORTC = 0;
TRISC = 0b10010001;
// spi init
SSPSTAT = 0b11000000;//
SSPCON1 = 0b00100000;// SPI Master mode, Fosc/4,0 = Idle state for clock

// spi test, write
while(1){
SPI_Write(0, 77);
x = SPI_Read(0); // in PRO ver. return 0 (zero)
if (x == 77) break;
}
}

Does anyone know what the problem is with the PRO version of the compiler?
Changed optimization has no effect, operation mode (Lite / Pro) has no effect ...
 

Are you setting the configuration bits in the MPLAB IDE or within the code?

What are the oscillator and PLL settings?

Have you compared the device specific header files, pic18f25k20.h between each version of the compilers?

I have noticed significant differences between header files of the various versions of the HiTech Compiler. I would suspect you'll find differences between v9.52 and v9.80.

BigDog
 

Are you setting the configuration bits in the MPLAB IDE or within the code?

What are the oscillator and PLL settings?

Have you compared the device specific header files, pic18f25k20.h between each version of the compilers?

I have noticed significant differences between header files of the various versions of the HiTech Compiler. I would suspect you'll find differences between v9.52 and v9.80.

BigDog

I am very aware of the differences in the header files, but do not see how this would lead to problems, because the registers are still at the same addresses have the same control bits ... ?

Maybe I should mention that I have 23 years experience in C programming, and 10 years in PIC C. :)

Maybe I overlooked some flag in 25K20 (but then would not work even with the STD version), so that it is a BUG or FEATURE:) in the PRO compiler version ???
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top