Jump to content

16F876

EstablishedMember
  • Content Count

    10
  • Joined

  • Last visited

Everything posted by 16F876

  1. From the PIC16F87X datasheet: Flag bit TXIF is set when enable bit TXEN is set. TXIF is cleared by loading TXREG.
  2. Finally got this thing to work. Problem is threefold. 1) The AD7706 needs a reset in the beginning. RB2 is tied to the reset and kept low for a while(reset) and then brought high to activate the chip again. 2) Polling the DRDY bit I could not get to work. So finally I polled the DRDY pin on the AD7706 and that worked. This I thought would work, but it did not: void DRDYX(void) //Data from ADC Ready? { delay_ms(1); SpiSend(0x08); //08h, Write to Comm register to read(poll) DRDY(Bit7)in comm register SpiSend(0x0); while(sspbuf&0x80) //Constantly poll com reg to se
  3. I am getting there slowly. Because the SPI is hardware driven I was under the impression that the chip would know when to receive answers or that the slave chip would tell the main chip to receive data. Well it does not work that way. After the chip is asked a question of which you want an answer, the data has to be "clocked out" of the chip being interrogated. This can be done by sending a dummy data to the chip. By sending a zero(0) by hardware SPI, clock cycles will be provided in exactly the same way to the slave chip, as it would if you where to "clock out"(bit bang) an answer
  4. Hi I disabled the RS232 before the use of SPI with no success. At http://forum.microchip.com/tm.asp?m=48978&...32&anchor#48978 is says "The I2C/SPI interface, and the USART are totally seperate, and do not affect each other." So far I have not found any other reference to disabling the RS232 before SPI use, but then there is very little information on using both at the same time. What did you mean by ? The Slave Select(SS) method is not used because the slave chip is hardwired as being selected. Thank you for your help I appreciate it.
  5. Hi there I am having trouble getting ADC values from an external AD7706( very similar to AD7705) IC to a PIC16F876 via SPI. The PIC is running at 4MHZ and the AD7706 is running at 2.4578 MHZ. I want to use the hardware SPI function(no bit banging) of the PIC and no interupts. I am trying to communicate to the external IC via SPI and want to report back to the computer via RS232. At the moment all the readings I get is zero and with my picoscope scope there seems to be no SPI data coming from the 16F876. void setup (void) { /* Setup*/ trisa=101111b; //make all portA
  6. Dear nic_steph Data can be read when a command was written to read data ie you send the command to read something, and right after it was sent the answer should be available. uchar SpiRead(uchar value){ uchar tmp; sspbuf = readcom; /*you put in here the command to read from certain register*/ while(bf == 0); /*wait for transmission completed and answer received*/ tmp = sspbuf; /*answer goes into tmp*/ } Depending on the device you might have to send quite a few commands before a read, but as soon as the final read command was sent and BF is set then the answer should be in s
  7. Hi There is a very nice tutorial at www.epemag.wimborne.co.uk/pictutorial.pdf
  8. You could multiply by 44, then divide by 9 to get a value that's roughly 0-5000 mV. <{POST_SNAPBACK}> My solution is so complicated that I would have gone with Steve's solution, but here goes: I get the ADC value in int multi. I multiply the value by 4.882 ( comes from 5000/1024, therefor 1023(+1) will be 5000) as follows: void Voltage (void) { multi=multi+1; // add one temp=multi*4; temp0=(multi*8)/10; temp1=(multi*8)/100; temp2=(multi*2)/1000; multi=temp+temp0+temp1+temp2; } Then I do the BCD extraction: void bcdext (void
  9. The device is the PIC16F876. You advice worked thank you very very much. I was working on this problem for a long time so thank you very very much.
  10. This following program does not compile with Sourceboost C2C Plus 5.3. It gives the error : Error: General error in function definition on line 72 which is exacltly the same as the code on line 78 namely, clear_bit (portc,RS) ; I have tried, output_low_port_c (RS); and clear_bit (portc,5); with no success. In general the code may be wrong for what I am trying to do, but it is the syntax that seems to be the problem. I have tried using hex instead of my prefered binary in some statements, but with no success. Please help me get this going. /* Trying to get to grips with this */
×
×
  • Create New...