--=====================_93158687==_ Content-Type: text/plain; charset="us-ascii"; format=flowed 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. TIA, Ed --=====================_93158687==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="TEST3.HEX" :0E000000830100308A00042883018A11902FAA :100F08008312881008003F308316860088013F301E :100F180085008701831208008A1187278A118A11A0 :100F2800D2278A118A11A4278A11A12F0512051E1A :100F38009E2F9F2FA12F881408149A2F8A110428F6 :100F480083120708A0002008FD388700323094007B :100F5800403083169400D530870093308312930075 :100F68000708A0002008023887000708A00020080A :100F7800FD398700643093000708A0002008023874 :100F880087000708A0002008FD398700E930930092 :100F98000708A00020080238870008008312070805 :100FA800A0002008FB3887003230940040308316B8 :100FB8009400D33087009330831293000708A00071 :100FC8002008043887000708A0002008FB3987009C :100FD800643093000708A000200804388700070839 :100FE800A0002008FB398700113093000708A000F3 :080FF8002008043887000800FE :00000001FF --=====================_93158687==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="TEST3.C" /* This is the C file for the receiver phase locked loop */ /* RA0 LD_LOW RA1 LD_HIGH RA2 GAIN_MEAS RA3 RSSI_MEAS RA4 ~SLEEP RB0 INTERRUPT RB1 S1_0 RB2 S1_1 RB3 S1_2 RB4 S1_3 RB5 S1_4 RC1 LE_HIGH RC2 LE_LOW SCK PLL_CLK SDI DATA SDO PLL_DATA TX TXD RX RXD RD0 RX_ENABLE RD1 ~SYN_SLEEP */ #include #define F_RX_LOW 0x000093 #define F_RX_HIGH 0X000093 #define F_TX_LOW OX000093 #define F_TX_HIGH 0X000093 #define R_RX_LOW 0X100064 #define R_RX_HIGH 0X100064 #define R_TX_LOW 0X100064 #define R_TX_HIGH OX100064 #define N_RX_LOW 0X000F11 #define N_RX_HIGH 0X00B8E9 #define N_TX_LOW OXOO1E81 #define N_TX_HIGH 0X00BEA1 #define LOW_PLL_LE_LOW_MASK 0XFB #define LOW_PLL_LE_HIGH_MASK 0X04 #define HIGH_PLL_LE_LOW_MASK 0XFD #define HIGH_PLL_LE_HIGH_MASK 0X02 #define PIC_CLK 4000000 #ifndef __DELAY_C #define __DELAY_C #include "always.h" #endif void Initialize_Ports() { TRISB=0x3F; // set port b as inputs TRISD=0x00 ; // set port d as output TRISA=0x3F ; // set port a as inputs TRISC=0x00 ; // set port c as outputs } void SetPLL_LOW() { unsigned char DUMMY ; DUMMY=PORTC; PORTC=(DUMMY | LOW_PLL_LE_LOW_MASK) ; //PUT LE FOR LOW PLL LOW SSPCON=0X32 ; // CLOCK DIVIDE BY 32 IN SPI MODE SSPSTAT=0X40 ; // DATA TX ON FALLING EDGE OF CLK -- MICROWIRE DEFAULT TRISC=0XD3 ; // WE SET THE TRISC BITS SSPBUF = F_RX_LOW ; // TRANSMIT RX_LOW F DATA DUMMY = PORTC ; // READ PORT C PORTC= (DUMMY | LOW_PLL_LE_HIGH_MASK) ; // PUT LOW PLL LE HIGH DUMMY = PORTC ; // READ PORT C PORTC = (DUMMY & LOW_PLL_LE_LOW_MASK) ; // PUT LOW PLL LE LOW SSPBUF=R_RX_LOW ; // TRANSMIT RX LOW R DATA DUMMY = PORTC ; // READ PORT C PORTC= (DUMMY | LOW_PLL_LE_HIGH_MASK) ; // PUT LOW PLL LE HIGH DUMMY = PORTC ; // READ PORT C PORTC = (DUMMY & LOW_PLL_LE_LOW_MASK) ; // PUT LOW PLL LE LOW SSPBUF = N_RX_LOW ; // TRANSMIT RX LOW N DATA DUMMY = PORTC ; // READ PORT C PORTC= (DUMMY | LOW_PLL_LE_HIGH_MASK) ; // PUT LOW PLL LE HIGH } void SetPLL_HIGH() { unsigned char DUMMY ; DUMMY=PORTC ; PORTC=(DUMMY | HIGH_PLL_LE_LOW_MASK) ; // PUT LE FOR HIGH PLL LOW SSPCON=0X32 ; // CLOCK DIVIDE BY 32 IN SPI MODE SSPSTAT=0X40 ; // DATA TX ON FALLING EDGE OF CLK -- MICROWIRE DEFAULT TRISC=0XD5 ; // WE SET THE TRISC BITS SSPBUF = F_RX_HIGH ; // TRANSMIT RX_HIGH F DATA DUMMY = PORTC ; // READ PORT C PORTC= (DUMMY | HIGH_PLL_LE_HIGH_MASK) ; // PUT HIGH PLL LE HIGH DUMMY = PORTC; // READ PORT C PORTC = (DUMMY & HIGH_PLL_LE_LOW_MASK) ; // PUT HIGH PLL LE LOW SSPBUF=R_RX_HIGH ; // TRANSMIT RX HIGH R DATA DUMMY = PORTC ; // READ PORT C PORTC= (DUMMY | HIGH_PLL_LE_HIGH_MASK) ; // PUT HIGH PLL LE HIGH DUMMY = PORTC; // READ PORT C PORTC = (DUMMY & HIGH_PLL_LE_LOW_MASK) ; // PUT HIGH PLL LE LOW SSPBUF = N_RX_HIGH ; // TRANSMIT RX LOW N DATA DUMMY = PORTC ; // READ PORT C PORTC= (DUMMY | HIGH_PLL_LE_HIGH_MASK) ; // PUT LOW PLL LE HIGH } void SYN_SLEEP() { RD1=0; // make synthesizers sleep } main() { Initialize_Ports() ; SetPLL_LOW() ; SetPLL_HIGH() ; while(1) // loop forever { if ( RA4 = 0 ) { RD1 = 1 ; RD0 = 1 ; } } } --=====================_93158687==_-- -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu