Upon further investigation, the same thing happens at Fosc/16. A 32-instruction loop fails (sends every other byte), a 33-instruction loop works (but one bit is one instruction time wider than the others). :-( This is really very unfortunate. This could be a nice efficient way to generate high-speed serial bit streams (eg: manchester), but.... Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) ----- Original Message ----- From: "Bob Ammerman" To: Sent: Monday, June 04, 2001 4:20 PM Subject: [PIC]: SPI hosing > I had hoped to be able to generate a continuous stream of bits at Fosc/4 > (ie: 8 instruction times per byte) using SPI mode on the MSSP on an 16F87x. > > Unfortunately, my testing seems to indicate this is a non-starter. > > I have successfully done this using the USART on an 18C, but I need the > USART for other purposes in the current application.application. > > Specifically, on the 18C USART in sync mode (and presumably the 16F87x's but > I haven't tested it), if I set SPBRG=0 and BRGH=1 then bytes can be sent > every 8 instruction times. I do this without testing the UART ready flag, > because I 'know' it will be set (and who has time to check it when sending > bytes this close together). > > I hoped (expected) to be able to use the same trick with the SPI mode of the > MSSP, but found that I had to allow an extra instruction time between each > byte (ie: 9 bytes per instruction). This causes a one-cycle 'hitch' in the > bit stream (and the sync clock). > > In other words, this 8-instruction loop doesn't work (specifically I get > every other byte): > > forever: > movlw B'10101010' ;[7] ;value to output > movwf SSPBUF ;[0] ;send it out > bsf PORTB,1 ;[1] ;sync output for 'scope > clrwdt ;[2] > bcf PORTB,1 ;[3] ;end sync > nop ;[4] > goto forever ;[5-6] > > But this 9-instruction one does (except for the extra 1-cycle hitch): > > forever: > movlw B'10101010' ;[8] ;value to output > movwf SSPBUF ;[0] ;send it out > bsf PORTB,1 ;[1] ;sync output for 'scope > clrwdt ;[2] > bcf PORTB,1 ;[3] ;end sync > nop ;[4] > nop ;[6] > goto forever ;[6-7] > > Anybody have any idea how to get around this? > > > Bob Ammerman > RAm Systems > (contract development of high performance, high function, low-level > software) > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body