ON 20060403@7:16:46 AM at page:
http://www.piclist.com/techref/microchip/memory.htm#38810.3032986111
Gregory Kirk Lundberg[GKL-ADS-EB2] See:
/techref/language/pcl/lj1202.htm
PCL5 HORIZONTAL MOTION INDEX ( HMI )
ON 20060403@10:40:10 AM at page:
http://www.sxlist.com/microchip/spi.htm#38810.2400810185
James Newton[JMN-EFP-786] published post 38810.2400810185
hadi.t.parizi@gmail.com asks:
Dear Sir/Madam,
I am developing SD memory card in SPI mode with PIC16F877A. My definition is inserted at the end of this email. But this setup does not work. When I run my code in PIC simulator, I came into conclusion that I have no output clock on PIN_C3. Would you please help me if you can!
Regards
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define SD_SELECT PIN_A5
#define SD_CLK PIN_C3
#define SD_DO PIN_C5
#define SD_DI PIN_C4
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
SETUP_SPI(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_4 | SPI_SS_DISABLED);
*0x94 |= 0x40; // set CKE = 1 - clock idle low
*0x14 &= 0xEF; // set CKP = 0 - data valid on rising edge
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|Delete 'P-' before: '' but after: 'delabs@gmail.com refers to "
http://www.delabs.net/
Process Control and Instrumentation Circuits."
|Delete 'P-' before: '' but after: '
Hi,
In the cooperative multitasking section of this page, there are comments and code regarding "cooperative multitasking routines [that] allow a task to return to the task scheduler *before* the end of it's main loop, and (once the task scheduler has run a few other routines) resumes executing right where it left off in that main loop".
At first I thought this was some really clever stuff, but after some examination, I'm not so sure this is different than things I achieve in a different way. It's quite conceivable that I'm missing some crucial nuance here, and I'd really like to learn what that is! ;-)
I would say there are actually 5 tasks in the example, not just "task1" and "task2". Let's call them "blah", "asdf", "etc", "stuff", and "zxcz". Please explain how the code below is any different than that proposed by Rich Leggitt
---- My cooperative multitasking scheme ----
call blah
call asdf
main
call etc
call zxcz
call stuff
call zxcz
goto main
blah nop
return
asdf nop
return
etc nop
return
stuff nop
goto blah
zxcz nop
goto asdf
---- End proposed equivalent code ----
I believe this code to be functionally equivalent to the original example. This code doesn't need W or a temp register to work. It is extensible by merely adding CALL statements in the main loop as-needed. It looks easier to me, but many of the contributors here are much better at this than I am. So, I offer my humble thanks to anyone who can explain the underlying difference between the two examples.
|Delete 'P-' before: '' but after: 'chminhtri@yahoo.com asks:
Hello to all, I am presently trying to program the PIC 16F876 to read in 2 analogue values on 2 different channels.But after the first reading , ADRESH:ADRESL registers continue to contain the value of the this conversion, so that result ofthe second reading is failed. How I can reset ADRES pair for futher reading ?
Thank you for your time and patience.
Tri Chau_Nha Trang City
|Delete 'P-' before: '' but after: '
Hi David,
It bugged me that I needed another RAM location for "flags". In retrospect, you could likely subsitute "data_byte,7" if you were short on general-purpose registers. When the last bit clobbers the flag during the RRL instruction, clock_line is already LO and Task5 is going to store the byte before Task2 can run.
kl~
|Delete 'P-' before: '' but after: 'kliebau@earthlink.net
Hi David,
Below is how I'd handle your example of a bit-banged serial receive under cooperative multitasking. We again don't need to preserve W, and other tasks can be added as desired without blocking. I do add one flag bit to the mix, and once that's done, other routines can use the other 7 bits of "flags" if needed without using any more RAM.
This was a quick spin -- there may be errors!
---- Proposed equivalent code ----
clock_line EQU PORTA,3
data_line EQU PORTA,5
data_byte res 1
bit_count res 1
flags res 1
clrf flags
call Task1 ; initialize the bit counter
Main:
btfss flags,0 ; don't bother with Task2 unless we've seen a LO on clock_line
call Task2
btfsc flags,0 ; don't bother with Task3 unless we've seen a HI on clock_line
call Task3
; check bit_count = 0 or check the C bit here, depending on which means is used
goto main ; if more bits, loop to main
call Task5 ; if no more bits . . .
; other tasks here as needed
goto main
Task1:
; load a bit counter with d'8'
movlw 8
movwf bit_count
; (Shouldn't we change this to
; use that clever method of loading the data byte with "1",
; then when that shifts into the carry bit,
; it signals we have a full 8 bits ... ?)
; [kl] - either way works!
Task2 ; watch the clock_line for a HI transition (without blocking other tasks)
btfsc clock_line
bsf flags,0
return
Task3 ; watch for the clock_line LO transition (without blocking other tasks)
btfss clock_line
goto Task4
return
Task4 ; grab the data bit and append it to data_byte
bcf flags,0
; grab the bit at this falling edge
rrl data_byte,f
; copy bit on data_line into lsb
; But first, get rid of random Carry flag that rrl shifted in
bcf data_byte,0
btfsc data_line
bsf data_byte,0
decfsz bit_count
return
Task5 ; store the received byte
movfw data_byte
call write_byte
nop
call Task1 ; re-init the bit counter
nop
return
---- End proposed equivalent code ----
I hope you like it!~
kl
|Delete 'P-' before: '' but after: 'sibycharley@yahoo.com asks:
i am in a terrible situation.i don't hav any idea about a2d conversions done using a pic and my need is to get the output of condenser mic as the input to the pic.
'
ON 20060413@7:15:55 AM at page:
http://www.piclist.com/microchip/index.htm#38820.2419791667
James Newton[JMN-EFP-786] removed post 38820.2419791667
|Delete '
/techref/microchip/FSK
'
ON 20060413 at page:
http://www.massmind.org/techref/microchip/16f877adsamp.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\16f877adsamp.htm.20060413.dif"
ON 20060413 at page:
http://www.massmind.org/techref/microchip/index.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\index.htm.20060413.dif"
ON 20060413 at page:
http://www.massmind.org/techref/microchip/new200604.txt
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\new200604.txt.20060413.dif"
ON 20060418@8:30:31 AM at page:
http://massmind.org/techref/microchip/multitasking.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\multitasking.htm&version=35
ON 20060418@1:21:00 PM at page:
http://www.piclist.com/microchip/picstartplusicsp.htm#38825.4377430556
James Newton[JMN-EFP-786] removed post 38825.4377430556
|Delete 'mabdulmadaka@yahoo.com asks: "
how and where to purchase the picstart plus programmer"
'
ON 20060418@5:30:54 PM at page:
http://massmind.org/techref/microchip/multitasking.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\multitasking.htm&version=36
ON 20060418@5:35:43 PM at page:
http://massmind.org/techref/microchip/multitasking.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\multitasking.htm&version=37
ON 20060418 at page:
http://www.massmind.org/techref/microchip/multitasking.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\multitasking.htm.20060418.dif"
ON 20060418 at page:
http://www.massmind.org/techref/microchip/new200604.txt
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\new200604.txt.20060418.dif"
ON 20060418 at page:
http://www.massmind.org/techref/microchip/picstartplusicsp.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\picstartplusicsp.htm.20060418.dif"
ON 20060419 at page:
http://www.massmind.org/techref/microchip/new200604.txt
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\new200604.txt.20060419.dif"
ON 20060419@10:45:03 PM at page:
http://massmind.org/techref/microchip/spi.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\spi.htm&version=22
ON 20060419@10:45:10 PM at page:
http://massmind.org/techref/microchip/memory.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\memory.htm&version=27
ON 20060419@10:45:39 PM at page:
http://massmind.org/techref/microchip/spi.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\spi.htm&version=23
ON 20060419@10:47:46 PM at page:
http://massmind.org/techref/microchip/spi.htm#
David A Cary[DAV-MP-E62a] edited the page. Difference:
http://massmind.org/techref/diff.asp?url=H:\techref\microchip\spi.htm&version=24
ON 20060420@4:22:07 PM at page:
http://techref.massmind.org/microchip/osc.htm#38827.2336921296
James Newton[JMN-EFP-786] published post 38827.2336921296
technique@fusadee.com asks:
I want to know witch crystal oscillator I take for LP mode because the capacitance used in LP mode ( page 57 data sheet :rfPIC12F675f ) is 68-100pF or CL =[(CL1 *Cl2)/(CL1+CL2)]+CS
So I must find an oscillator at 32Khz with 40 pF to 60 pF as CL .or it is not the norm in Europe(12.5pF) .I d like to know if there a new version of data sheet to resolve this problem or witch solutions I must take to LP mode .
Thank you
|Delete 'P-' before: '' but after: '' with: ''
ON 20060426 at page:
http://www.massmind.org/techref/microchip/new200604.txt
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\new200604.txt.20060426.dif"
ON 20060426 at page:
http://www.massmind.org/techref/microchip/rnocarry.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\rnocarry.htm.20060426.dif"
ON 20060427@12:39:00 PM at page:
http://www.piclist.com/techref/microchip/bigtable.htm#38834.5270833333
Guy Griffin[GG-griffin-I8] Says
PCLATH is only modified explicitly, i.e. the PIC never changes it. Multiple computed GOTOs must set PCLATH appropriately before each PCL write, otherwise you'll get a jump to an unexpected address.
For example, a moving-message display: a small table lookup uses ADDWF PCL,f to returns the next ASCII code from a series. Then a large page-crossing table returns a column of pixels for display, probably modifying PCLATH in the process. This works OK the first iteration only - as the little table doesn't setup PCLATH, it gets implicitly loaded into PC the next time around... resulting in a jump to some unknown place in the middle of the code, and a large headache to debug.
ON 20060427 at page:
http://www.massmind.org/techref/microchip/bigtable.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\bigtable.htm.20060427.dif"
ON 20060427 at page:
http://www.massmind.org/techref/microchip/new200604.txt
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\new200604.txt.20060427.dif"
ON 20060429 at page:
http://www.massmind.org/techref/microchip/picstartplusicsp.htm
someone[--] edited the page. Difference:
"R:\bak\H\techref\microchip\picstartplusicsp.htm.20060429.dif"
ON 20060429@9:38:03 PM at page:
http://www.piclist.com/microchip/picstartplusicsp.htm#38836.2620138889
James Newton[JMN-EFP-786] published post 38836.2620138889
http://www.embedinc.com/picprg/icsp.htm
See this link for a general discussion of circuit design considerations for ICSP.
|Delete 'P-' before: '' but after: '
/techref/microchip/pic+asm
'