ON 20060925@1:58:40 PM at page:
http://www.piclist.com/piclist/cheapic/alphabet.htm#38985.4622685185
James Newton[JMN-EFP-786] removed post 38985.4622685185
|Delete '
/techref/piclist/cheapic/infra red
'
ON 20060925@2:02:59 PM at page:
http://www.piclist.com/piclist/cheapic/alphabet.htm#38985.1042361111
James Newton[JMN-EFP-786] Published and replied to post 38985.1042361111 by not4you
|Insert 'In most assembly langauges, "$" refers to the current address in the program. goto $ puts the processor into an infinite loop by telling it to branch back to the address of the goto.' at: ''
not4you@net.hr asks: "
hey there! can anyone explain me this atribut: goto $
best regards. thnx"
|Delete 'P-' before: '' but after: 'mjhei89@yahoo.com asks: "
why is each instruction is about 122 microseconds long? I am a beginner in PIC, thanks a lot to your explanation."
ON 20060925@2:07:42 PM at page:
http://www.piclist.com/techref/piclist/cheapic/alphabet.htm#37708.2865509259
James Newton[JMN-EFP-786] removed post 37708.2865509259
|Delete '
First of all I want to say: Great tutorial! and Thanks !!
I try to change bit time delay to 26usec and use 38400 baud connection, but no matter what my sent, it always relay with "01 02 03" (HEX).
Anybody can help me out?
;-----------------------------------------------------------------------;
; transmit byte in W at 38400 baud out RB7 ;
;-----------------------------------------------------------------------;
; normal rs232 is -V for a high, +V for a low
; this would translate to 0V for high +5 for low
tx:
movwf txreg ; set up transmit register
comf txreg, f ; flip all bits
movlw D'8' ; eight bits to transmit
movwf bitcount
bsf PORTB, 7 ; start bit (+5V is 'low')
movlw D'5' ;
call micro4 ; 1(mov) + 2(call) + [4 * 4 + 5] = 24
txloop:
rrf txreg, f ; lsb out of txreg into carry
rrf PORTB, f ; bit 7 of port B high or low with carry
movlw D'4' ;
call micro4 ; 1(mov) + 2(call) + [4 * 3 + 5] = 20
nop ; Make it delay for 21
decfsz bitcount, f ; 4 instruction cycles to here
goto txloop ; total 4 + 3 = 7 instructions cycles in loop
nop ; Make 1 + 1(bcf) +24 for last bit delay
bcf PORTB, 7 ; 0 Volts is the 'high' state this is
movlw D'5' ;
call micro4 ; 1(mov) + 2(call) + [4 * 4 + 5] = 24
return ; 24 + 2(return) = 26 for stop bit
;-----------------------------------------------------------------------;
; receive byte at 38400 baud in RA0, put in W ;
;-----------------------------------------------------------------------;
rx:
startbit:
btfss incom ; 2 for startbit
goto startbit ;
movlw D'1' ;
call micro4 ; 1 + 2 + 5 = 8 usec
nop ; make 1 more delay
btfss incom ; 2 for still on high (till here start bit pass 13 usec)
goto startbit ; 2, Not a start bit, back to wait
movlw 8 ; 1, (Here ready for first Data bit, need delay for 26 usec)
movwf bitcount ; 1
clrf rxreg ; 1, clear out register
movlw D'4' ;
call micro4 ; 1 + 2 + (4 * 3 + 5) = 20 (total here is 23)
nop ; 1
nop ; 1, make to 25 usec delay
receive:
rrf PORTA, f ; 1, PORT A bit 0 into carry (till here Finish 26 usec delay)
rrf rxreg, f ; 1, rotate carry into receive register (start For Next Bit)
movlw D'4' ;
call micro4 ; 1 + 2 + (4 * 3 + 5) = 20
nop ; 1, make to 22 usec delay (total here is 22)
decfsz bitcount, f ; 1(2)
goto receive ; 2
nop ; 1, last bit delay 25
comf rxreg, W ; 1, Flip All Bits (End Of Last Bit 26 usec delay)
movlw D'5' ; ( Wait For Stop Bit Start From Here)
call micro4 ; 1 + 2 + (4 * 4 + 5) = 24
return ; 2 (Stop Bit Completed)
end
'