PersonalSoundtrack: Development Blog

The open-source music player that detects your walking or running speed and plays songs from your music library that match your pace. Song speed is adjusted in real-time to match subtle variations in your gait, while larger, deliberate pace changes cause the device to change songs. You simply put it on and begin moving; that's it.

Sunday, November 05, 2006

xtal (cystal)!

ok, i'm a newbie. i wasn't using an external crystal for the pic timing. apparently the internal oscillator is useless. (thanks tom!)

so here's my new schematic. i'll be using an 18.432MHz xtal. it has three connections: two connect to clk1 and clk2 on the pic, and one connects to VDD.

tom also sent me some quick code that uses the USART component of the pic, so i don't have to do bit-banging anymore.

code snippet (courtesy tom jennings):

(cut and paste it directly, there are tabs in there that html isn't displaying)

; Initialize the UART for asyncrhonous in and out
; and set the bit rate. This sets PB2 (TD) as output,
; PB1 (RXD) as input and sets the bit rate to the factor
; W. See PIC16F628a data sheet PDF page 73-75.

banksel TRISB ; bank
bsf TRISB, RXD ; 1 RB1 is input, RD
bcf TRISB, TXD ; 1 RB2 is output, TD

bcf TXSTA, BRGH ; 1 set LOW B.R. range,
movwf SPBRG ; 1 set bit rate divisor,

bsf TXSTA, TXEN ; 1 Tx enable

banksel RCSTA
bsf RCSTA, SPEN ; 0 Rx enable,
bsf RCSTA, CREN ; 0 continuous Rx,


; Output W to the UART.

serout banksel PIR1
__so1 btfss PIR1, TXIF ; Tx full
goto __so1 ; wait...
movwf TXREG ; output to transmitter.



Post a Comment

<< Home