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.

asking about the meaning of a dummy output

Status
Not open for further replies.

boukamoha

Member level 5
Joined
Aug 3, 2012
Messages
85
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,891
hi every one ..i have this part of the program ..

char dummy;
CE = 1;
Send_To_TC72(0x80);
dummy = SSPBUF;
Send_To_TC72(0x11);
CE = 0;
dummy = SSPBUF;
Delay200ms( );

can some one tell me exactlly the meaning of the dummy variable? and when can i use it...
thx in advance
 

hi
we need all program to understand dummy,
i think this is only a char named dummy.
 

hi every one ..i have this part of the program ..

char dummy;
CE = 1;
Send_To_TC72(0x80);
dummy = SSPBUF;
Send_To_TC72(0x11);
CE = 0;
dummy = SSPBUF;
Delay200ms( );

can some one tell me exactlly the meaning of the dummy variable? and when can i use it...
thx in advance

it looks as though the code is writing the value 0x11 into the control register (0x80) of a TC72 digital temperature sensor
the statements
Code:
dummy = SSPBUF;
reads the value in the SPI serial transmit/receive register (and then appears to discard it) before the next write. I don't think you need to do this but we have to see the rest of the code.
I tend to write the SPI buffer, wait for it to complete and then read it in a function so (this is for a PIC24)
Code:
// send one byte of data and receive one back at the same time
unsigned char writeSPI1( unsigned char i )
{
    SPI1BUF = i;                      	// write to buffer for TX
    while(!SPI1STATbits.SPIRBF) Nop();  // wait for transfer to complete
    return SPI1BUF;                    	// read the received value
}
 

hi horace1
thx for your response..in reality i want to connect two pic microcontollers using the spi protocol can you give me more details about this kind of connection with an example c code...
thx in advance
 

hi horace1
thx for your response..in reality i want to connect two pic microcontollers using the spi protocol can you give me more details about this kind of connection with an example c code...
thx in advance
should be no problem so long as the SPI configuration is the same in terms of baud rate and other parameters.
make one the master the other a slave? have a look at Microchip's sample code
**broken link removed**
 

ok i've got the aimed code ..thank you for help..
cheers..
 

hi horace1
i've read the codes from microship but i still didn't understand how to write to a microcontroller and get the response...for example in my case i want to perform a simple mathematical operation and send the comands from the first microcontroller to perform that operation in the second one , but the results will be displayed in LCD connected to the first microcontroller , so the question is how i can proceed to send the write and read commands , like we use to do in the TC72 digital sensor .
another question can you tell me please which registers in the SLAVE microcontroller should i work?
cheers..
 

have a look at
ww1.microchip.com/downloads/en/devicedoc/spi.pdf

it discusses SPI and the programming of a SPI master and slave with example code
 

thx.. now i'm doing a progress
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top