PDA

View Full Version : PIC routines for serial communications


majid
06-19-2002, 05:45
Hi,

can any body, give info. about serial communications at different baud rates using PIC microcontrollers (16F84 for example)

so, any info or source code of clip even old.. will be welcome :)

BR;

---
Majid
majid@gsm54.net

Saulyss
06-19-2002, 18:20
Search for highlevel PIC compiler , (C language as example) , there will be already build in serial communication funtion's .

majid
06-19-2002, 21:48
is there a free C compiler for 16F628 ?

Thanks

Saulyss
06-20-2002, 00:39
Try to search .... and after www.astalavista.box.sk .......

ZzX
06-20-2002, 02:15
hi
you can with
4 mhz=posible to up 57600 boaund %0.0.1 error
8 mhz=posible to up 115200 boaund %0.1 error

rutin
SendChar232 ;
movwf SerByte ; store char to send out
movlw 8 ;
movwf BitsToGo ; # bits to send out
bcf TXpin232 ; send out start bit
movlw 0x56 ; [1] set length for start bit
Delay3W ; [258]
TXLoop232 ;
rrf SerByte ; [1]
btfsc STATUS,C ; [1] is it a 1?
goto TXOne232 ; [2] yes - send a '1'
bcf TXpin232 ; [1]
nop ; [1]
movlw 0x54 ; [1]
Delay3W ; [252]
decfsz BitsToGo ; [1]
goto TXLoop232 ; [2]
goto DoneByte232 ;
TXOne232 ;
bsf TXpin232 ; [1]
movlw 0x54 ; [1]
Delay3W ; [252]
decfsz BitsToGo ; [1]
goto TXLoop232 ; [2]
DoneByte232 ;
bsf TXpin232 ; [1] send out stop bit
movlw 0x54 ; [1]
Delay3W ; [252]
bsf TXpin232 ; idle state for TXpin
return ;









;)

majid
06-20-2002, 03:23
@ Saulyss : I found C2C and PICC which one is good for 16F628 ans for serial comm.

@ ZzX : Thanks man for this source ;)
but the source is not complete, how to change baudrate and the delay function misses ...

I searches on the net I found some routines but each one if for a baud rate/ frequency, and need to use some formula to calculate delays ....

I will try to search more ;)

BR;
Majid

Saulyss
06-20-2002, 04:33
Check http://www.ccsinfo.com/ , i'm using this compiler , there a lot off built in function's I2C , SPI communication ....

Saulyss
06-20-2002, 04:36
16F628 have build in hardware UART, so there u can avoid delay's and etc. And communcation can be completly interrupt based ....

Regard's

ZzX
06-20-2002, 07:08
one calculate example you can modify
16F84 running at 10MHz - 9600 baud, 1bit=104uS => 260.4 cycles

majid
06-22-2002, 02:43
Thanks brothers for advices :-)

Majid