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.

Software SPI and I2C in HiTech C not working

Status
Not open for further replies.

john blue

Advanced Member level 3
Joined
Jun 7, 2007
Messages
821
Helped
213
Reputation
430
Reaction score
204
Trophy points
1,323
Activity points
4,749
Currently, I have just tried out the software SPI and I2C. Both are not working. If I used the hardware based, then, i get no problem. But, I need one of them to be software based. Anyone can please help? Thanks in advance.
 

can you put the code here.. did you test it in proteus simulator???

seems to be header file problem... put the simulated output so that we can understand the problem better...

where did you get the header files from?????
 

hai john,

I am new to this forum to post.

"Currently, I have just tried out the software SPI and I2C. Both are not working. If I used the hardware based, then, i get no problem. But, I need one of them to be software based."

May i know what did u meant exactly "software based" and "Hardware based"?

Regards,
karthikkr
 

karthikkrv85 said:
May i know what did u meant exactly "software based" and "Hardware based"?

"Hardware based" means protocol working with dedicated hardware like MCU registers, maybe interrupt driven etc. "Software based" is when you make the protocol by yourself, meaning toggling clock by software and driving bytes bit by bit to port pin. This is also called "bit banging".

Bit banging - Wikipedia, the free encyclopedia
 

Ya i can understand bit banging. But this is what Mr.John meant is my question? we can see his code or the CRO pulses to figure out the problem.

Thanks for your reply
 

Ya i can understand bit banging. But this is what Mr.John meant is my question? we can see his code or the CRO pulses to figure out the problem.

Thanks for your reply

Yes it is. I am bit banging my SPI and I2C :)
 

Hi John Blue,

Are you implementing these in a Proteus Simulation or physical hardware?

BigDog
 

Not that I have encountered, but you certainly have a knack for finding Proteus' weaknesses. :wink:

Can you upload your Proteus Simulation and code?

BigDog
 

hi,
you may want to do the i2c protocol in software
there is a working example of software I2c here:
software I2c
the project is done with 8051 but I but I believe since it's just software I2c it should work with PIC
 
Hi

I have going to interface the MSP430f5438 with digital potentiometer MCP41010 by SPI communication.For that i have write the code as below.My spi had some problem because of that i am not able to write the value in the data registers.If you had any solution for me then please send me.





void spi_init(void)
{

//unsigned char spi_cmd,spi_data;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer

P10OUT |= 0x01; //Chip select
P10DIR |= 0x0B; // Set P10-0,3,1 to output direction
P10SEL |= 0xA; // P10.1,3 option select for the si and clk

UCB3CTL1 |= UCSWRST; // **Put state machine in reset**
UCB3CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCB3CTL1 |= UCSSEL_2; // SMCLK
UCB3BR0 = 0x02; // /2
UCB3BR1 = 0; //
//UCA3MCTL = 0; // No modulation
UCB3CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
// UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

P10OUT &= ~0x01; // Now with SPI signals initialized,
P10OUT |= 0x01; // reset slave


}

void spi_write(unsigned char data)
{
while (!(UCB3IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCB3TXBUF = data;

}

void main (void)

{

spi_init();

P10OUT&=~0x01

delay(1000);
spi_write(17); //command set for the digital pot IC

spi_write(0); //values given to the data register
delay(1000);
P10OUT|=0x01

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top