Ed wrote: >I have a very simple application for a pic 16c74b. (Yes, I know it is gross >overkill, but that is what we are using.) Basically, it is being used to >program two National Semiconductor synthesizers. They use the standard SPI >bus, which has a data, a clock, and an enable line. I am using (or at least >trying to use) RC5 for data, RC3 for clock, and RC2 for low synthesizer >enable and RC1 for high synthesizer enable. The code seems to do nothing at >all, in either MPLAB or on the actual board. Basically, nothing toggles or >does ANYTHING! I am sure I am doing something incredibly stupid, or lacking >some very simple line of code to set something up, but I can't figure out >the problem at all. I am attaching a copy of the c code (I used a Hi-Tech >compiler), but I don't believe there is anything non-standard in the code, >and the actual hex code that was generated by the Hi-Tech compiler. The >only error messages I get are not errors but warnings indicating math >overflow in lines 85, 90, 110, 115, which are SSPBUF=R_RX_LOW, >SSPBUF=N_RX_LOW, SSPBUF=R_RX_HIGH, and SSPBUF=N_RX_HIGH. It seems >especially unusual that it gives warnings for those lines, but not other >lines where SSPBUF is set, which are essentially equivalent. > >Any help on where my problem is would be greatly appreciated. As I said, >this is very simple, and the fact that nothing happens tells me that I am >just overlooking something very simple. Well, for starters, you seem to be trying to send 24 bits via SPI, but SSPBUF = whatever; will only place the lowest 8 bits of whatever into SSPBUF. It's an 8-bit register, after all ... you're getting an error because those lines contain 24-bit with a non-zero most significant byte. The other values you've defined (e.g. F_TX_LOW) are just 8-bit values sign- extended to 24 bits. If you want to send three bytes, you need to load SSPBUF three times, AND ensure that the previous byte has been sent before loading the next, e.g. SSPBUF = R_RX_LOW & 0xFF; delay until byte is sent; SSPBUF = (R_RX_LOW >> 8) & 0xFF; delay until byte is sent; SSPBUF = (R_RX_LOW >> 16) & 0xFF; In actual practice, I believe the SPI subsystem is double- buffered, so you can probably do away with the first delay, but you will have to wait or poll between the second and third bytes being sent. More importantly, you have a typo. it Should read while (1) // loop forever { ... } not while (1); // loop forever { ... } Didn't the coimpiler complain about "unreachable code"? Regards, -- -- ______________________________________ Andrew E. Kalman, Ph.D. aek@pumpkininc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu