Searching \ for '[PIC]:Strange SPI problem with PIC16F877. NEED HEL' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=spi
Search entire site for: 'Strange SPI problem with PIC16F877. NEED HEL'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:Strange SPI problem with PIC16F877. NEED HEL'
2001\01\06@061106 by linus_dillon

picon face
No one replied to my last post. I though I might try again with information
from my past week of investigation.

The specific problem is that however I initialise the MSSP, the only four
SCK pulses are sent for each byte transmitted. It appears as if it is
shifting out/in data on EVERY clock edge rather than on only the rising or
falling edges. I suspect a hardware fault in the PIC. I have tried this with
two chips (both likely to be from the same batch however), at different
clock rates. I have tied all unused pins low via resistors, and no reset or
interrupt is occurring in the middle of the transfer.

If anyone can simply confirm that I am not missing anything obvious then
that would be a great help! Or, if anyone has had similar problems, then I'd
be very happy to hear about it.

Here is the generated assembly code (I am coding in C using the C2C
compiler):



   ;;;;;;;;char T2CON@0x12;
   ;;;;;;;;char PR2@0x92;
   ;;;;;;;;char TRISC_REG@0x87;
   ;;;;;;;;char PORTC_REG@0x07;
   ;;;;;;;;
   ;;;;;;;;char SSPSTAT@0x94;
   ;;;;;;;;char SSPCON@0x14;
   ;;;;;;;;char SSPCON2@0x91;
   ;;;;;;;;char SSPBUF@0x13;
   ;;;;;;;;
   ;;;;;;;;void main(void)
_main__code
   ;;;;;;;;{
   ;;;;;;;;    char result;
   ;;;;;;;;
   ;;;;;;;;    PIE1 = 0x00;                    // disable interrupts
   bsf STATUS, RP0
   bcf STATUS, RP1
   clrf _PIE1
   ;;;;;;;;    INTCON = 0x00;
   clrf INTCON
   ;;;;;;;;
   ;;;;;;;;    SSPCON = 0x00;            // clear SSPCON register
   bcf STATUS, RP0
   clrf _SSPCON
   ;;;;;;;;
   ;;;;;;;;    TRISC_REG = 0x10;        // SI is input, all other output
   movlw D'16'
   bsf STATUS, RP0
   movwf _TRISC_REG
   ;;;;;;;;
   ;;;;;;;;    PORTC_REG = 0x01;         // raise CS output
   movlw D'1'
   bcf STATUS, RP0
   movwf _PORTC_REG
   ;;;;;;;;
   ;;;;;;;;    SSPSTAT = 0x00;            // clear SSPSTAT
   bsf STATUS, RP0
   clrf _SSPSTAT
   ;;;;;;;;    SSPCON = 0x12;            // configure for Fosc/64, clock
inactive high
   movlw D'18'
   bcf STATUS, RP0
   movwf _SSPCON
   ;;;;;;;;
   ;;;;;;;;    set_bit(SSPCON, 5);        // enable SPI
   bsf _SSPCON, D'5'
   ;;;;;;;;
   ;;;;;;;;    PORTC_REG &= 0xFE;        // drop CS output
   movlw D'254'
   andwf _PORTC_REG, F
   ;;;;;;;;
   ;;;;;;;;    delay_us(100);                    // wait for 100us
   movlw D'100'
   movwf param00_delay_us
   call _delay_us
   bcf PCLATH, 3
   bcf PCLATH, 4
   ;;;;;;;;
   ;;;;;;;;    SSPBUF = 0xF0;                // Send 0xF0
   movlw D'240'
   bcf STATUS, RP0
   bcf STATUS, RP1
   movwf _SSPBUF

.. and so forth. Code placed here DOES execute.

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...