Chirurgia cranio-cerebrală minim invazivă
Tehnicile minim invazive impun utilizarea unei tehnologii ultramoderne. Endoscoapele operatorii de diverse tipuri, microscopul operator dedicat, neuronavigația, neuroelectrofiziologia, tehnicile avansate de anestezie, chirurgia cu pacientul treaz reprezintă armamentarium fără de care neurochirurgia prin "gaura cheii" nu ar fi posibilă. Folosind tehnicile de mai sus, tratăm un spectru larg de patologii cranio-cerebrale. www.neurohope.ro |
Folosirea comunicatiei seriale RS232
Last Updated: Jul 30 2004 07:52, Started by
carst_razvan
, Jul 27 2004 09:21
·
0
#1
Posted 27 July 2004 - 09:21
Vreau sa trimit litera "A" folosind RS232 la un calculator. Cum s-ar putea face? (Am incarcat valoarea 0x41 intr-un registru, apoi am folosit un exemplu de program de pe internet care nu prea merge. Cred ca pt. a face transmisia seriala tre' sa folosesc un protocol de comunicatie. Banuiesc ca este Non Return to Zero. Programul folosit este:
" LIST P=16F84a ; tells which processor is used #INCLUDE "p16f84a.inc" ; defines various registers etc. Look it over. #include "bank.inc" ERRORLEVEL -224 ; supress annoying message because of tris __CONFIG _PWRTE_ON &_LP_OSC &_WDT_OFF ; configuration switches CBLOCK H'0C' txreg ; holds byte to be transmitted rxreg ; holds byte received char ; holds character to be transmitted bitcount ; holds count of bits when transmitting timecnt ; holds counter for timer cont ENDC ORG 0 ; start a program memory location zero goto main ; skip over subroutines ;-----------------------------------------------------------------------; ; initialization - set up ports and timer options ; ;-----------------------------------------------------------------------; init: BANK1 movlw 0x1F movwf TRISA BANK0 movlw 0x01 ; RA0 to input movwf PORTA ; contents of W copied to PORT A ... BANK1 movlw 0x00 movwf TRISB BANK0 movlw 0xFF movwf PORTB ; and PORT B BANK1 movlw 0x01 ; pull-ups active movwf OPTION_REG ; prescalar assigned to TMR0 and set 1:4 rolls over each second return ;-----------------------------------------------------------------------; ; time delay routines ; ;-----------------------------------------------------------------------; onesecond: BANK0 movlw 0x6F ; wait one second movwf timecnt clrf TMR0 bcf INTCON, T0IF ; clear the interrupt flag time: btfss INTCON, T0IF ; wait on T0IF to be set goto time ; loop till it is decfsz timecnt, 1 ; finished timing? goto time ; not yet return ; yes ;-----------------------------------------------------------------------; ; the main program ; ;-----------------------------------------------------------------------; main: ; this is the main program call init ; set up ports call onesecond ; let things settle for 1 second loop: ;call rx get a character from keyboard BANK0 ;movwf char save so we can increment it movlw 0x41 movwf char incf char, f ; send back the next 3 characters movf char, W call tx incf char, f movf char, W call tx incf char, f movf char, W call tx incf char, f movf char, W call tx incf char, f movf char, W call tx incf char, f movf char, W call tx incf char, f movf char, W call tx incf char, f movf char, W call tx ;goto loop do it forever ;-----------------------------------------------------------------------; ; transmit byte in W at 1200 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') nop ; a total of 7 instruction cycles nop ; (one is the rrf at txloop) nop nop nop txloop: rrf txreg, f ; lsb out of txreg into carry rrf PORTB, f ; bit 7 of port B high or low with carry movlw 0x57 movwf cont test1: decfsz cont,1 goto test1 ; make total loop delay 7 instruction counts ; 7 * 122 usec = 854, (should be 833) decfsz bitcount, f ; 4 instruction cycles to here goto txloop ; total 4 + 3 = 7 instructions cycles in loop bcf PORTB, 7 ; 0 Volts is the 'high' state this is nop ; stop bit nop ; delay 7 instruction cycles nop nop return ;-----------------------------------------------------------------------; ; receive byte at 1200 baud in RA0, put in W ; ;-----------------------------------------------------------------------; rx: movlw 0xFF ; eight bits to input movwf bitcount waspam.spam: btfss PORTA, 0 ; wait for input to go high, (start bit) goto waspam.spam nop ; wait 1/2 start bit time 3 including branch nop ; next four instruction are to make nop ; 1 bit time delay before first reading of nop ; input port nop receive: ; make total loop delay 7 instruction counts ; 7 * 122 usec = 854, (should be 833) movlw 0x57 movwf cont test: decfsz cont,1 goto test rrf PORTA, f ; PORT A bit 0 into carry rrf rxreg, f ; rotate carry into receive register decfsz bitcount, f ; goto receive ; total 4 + 3 = 7 instructions cycles in loop comf rxreg, W ; return compliment of value collected nop ; wait at least one stop bit nop nop nop return end " Am adaptat putin programul pt. rezonatorul meu de 455 KHz) |
#2
Posted 27 July 2004 - 17:37
Poate ca o sa zica lumea ca sunt nebun (!), dar de ce nu folositi limbajul JAL, oameni buni?!?
Pt transmisii sincrone sau asincrone de date pe seriala nu trebuie scrisa decat o linie de cod !!! Eu am programat PIC-uri si in asamblare o vreme, dar nu o sa mai pun mana pe el decat daca trebuie facut ceva ce nu se poate face in JAL! Uite un exemplu: include 16f84_4 include jlib include serial asynch_send ("A") asynch_send (ASCII_CR) asynch_send (ASCII_LF) Nu e mai simplu asa?!? Bafta! |
#3
Posted 28 July 2004 - 13:58
JAL trebuie apelat din Command Prompt? Exista vreo versiune pentru Windows?
|
#4
Posted 28 July 2004 - 19:27
Eu am cautat o versiune pentru Windows si nu am gasit nicaieri, in linie de comanda habar nu am ca trebuie sa fac
|
#5
Posted 28 July 2004 - 20:16
din pacate, ruleaza din linie de comanda, dar odata facut un fisier *.bat, treaba se rezolva prin simpla apelare a acestuia...
Am vazut zilele trecute pe net un program in windows care apela JAL-ul si permitea editarea sursei in editorul propriu...nu stiu daca se justifica atata timp cat un editor bun este si notepad-ul... in cazul meu, fisierul bat are continutul: c:picjalbinjal.exe -sc:picjallib c:picjalworktest.jal unde test.jal este sursa la care lucrez... Bafta! |
#8
Posted 29 July 2004 - 11:17
ai grija la numele directoarelor unde este pus JAL-ul si fisierul in care lucrezi...sau foloseste editorul de la deejay2k1
Bafta! |
#9
Posted 29 July 2004 - 13:27
Editorul deejay2k1 unde il pot gasi?
Daca tot pot folosi jal-ul, ajutati-ma cu ceva documentatie Multumesc |
#10
Posted 29 July 2004 - 19:19
Editorul il poti gasi cu 2 posturi mai sus... :ciocan:
Documentatie.....cauta pe net... :cya: |
|
Anunturi
▶ 0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users