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.

Problem with the SSP1BUF register

Status
Not open for further replies.

ADGAN

Full Member level 5
Full Member level 5
Joined
Oct 9, 2013
Messages
295
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Visit site
Activity points
1,837
Hi! I converted a code written for PIC18F65J90 to PIC18F45K22. The original code is as follows:
Code:
 void Output(UINT8 Data)
{
unsigned char ClearBuffer;

    while(SSPSTATbits.BF ==1)
        ClearBuffer = SSPBUF;
    
    SSPBUF = Data;
    PIR1bits.SSPIF = 0;
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    while(!PIR1bits.SSPIF);
    Nop();
    Nop();
    ClearBuffer = SSPBUF;
    
    return;
}

My code is this:
Code:
void Output(UINT8 Data)
{
unsigned char ClearBuffer;

    while(SSP1STATbits.BF ==1)
        ClearBuffer = SSP1BUF;
    
    SSP1BUF = Data;
    PIR1bits.SSP1IF = 0;
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    while(!PIR1bits.SSP1IF);
    Nop();
    Nop();
    ClearBuffer = SSP1BUF;
    
    return;
}
But when I simulate the original code in Proteus I see some data is been moved on the data bus. But when I test my code I don't see any data on the data bus. What could be the reason for this? I'm using MPLAB C18.
 
Last edited:

How is Init_Delay() declared? Maybe is a matter of simulation timing... the code reach a stall state inside this function.
Check the oscillator and the timestep in simulation.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top