Hallo,
habe einen Atmega128, der mit 19200 Baud (8n1) permanent ein CHR(50) mit 100 ms Pause an einen PIC 16F873a sendet.
Leider habe ich es mit PicBasic nicht hinbekommen, dass dieser Wert von der UART eingelesen werden kann. Ich bekomme da immer falsche Werte heraus.
Das Programm sieht folgendermaßen aus:
Hab mal ausprobiert, welche Werte eingelesen wurden. Meistens lagen die über 200. Waren aber meistens unterschiedliche Werte.Code:' Definitionen define osc 4 include "modedefs.bas" starta: TRISC = %10000000 ' PORTC.7 is the RX input ' PORTC.6 is the TX output DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_BAUD 19200 ' 19200 Bauds DEFINE HSER_CLOERR 1 ' Alias definition ' ================ ' ' RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty) TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full) pause 10 ' safe start-up delay ' Port-Definitionen adcon1 = 7 'Ports auf digital p1 var porta.0 p2 var porta.1 p3 var porta.2 p4 var porta.3 p5 var porta.5 p6 var portc.0 p7 var portb.7 p8 var portb.6 p9 var portb.5 p10 var portb.4 ELEIN var portc.1 s1 var word s2 var word s3 var word s4 var word s5 var word s6 var word s7 var word s8 var word s9 var word s10 var word s11 var word s12 var word s13 var word s14 var word s15 var word s16 var word s17 var word s18 var word Bus_out var byte Bus_out_alt var byte zaehler var word Bus_in var Byte Bus_in1 var byte busrw var portc.5 ' Ports als Ein- bzw. Ausgang input porta.3 input porta.5 input portc.0 input portb.7 input portb.6 input portb.5 input portc.7'rxd output porta.0 output porta.1 output porta.2 output portc.1 output portc.5 ' Hauptprogramm high ELEIN 'EL-Folie und Display beim Start ausschalten 'pause 5000 'high busrw 'für senden = high, für empfangen = low Schleife: low busrw if RCIF then ' incomming data? hserin [Bus_in] ' take it if Bus_in = 50 then low ELEIN 'EL-Folie einschalten endif endif goto Schleife
Der Sender stimmt 100%ig, mit dem schicke ich noch Daten an andere Kontroller.
Hat jemand eine Idee, was an dem Code falsch sein kann?
Mfg,
Thorsten Wurm







Zitieren

Lesezeichen