Re: [Flashforth-devel] PIC18fxxk90
Brought to you by:
oh2aun
From: <zd...@al...> - 2016-05-01 20:48:04
|
No, it didn't work for UART2. Transmit didn't work because the initialization was missing. You should just add #ifs and #endifs: movlw spbrgval ; movwf SPBRG, A banksel SPBRG2 movwf SPBRG2, BANKED ; TX enable movlw b'00100100' ; movwf TXSTA, A banksel TXSTA2 movwf TXSTA2, BANKED Receive didn't work because RX2 is also an analog pin and while UART takes care about TRIS setting, analog pin takes priority. This is (probably) correct code: ; RX enable #if UART == 1 #ifdef ANSELH #ifdef ANS11 bcf ANSELH, ANS11, A ; Enable digital RB5 for RX(1) #endif #endif #ifdef ANSELC #ifdef ANSC7 banksel ANSELC bcf ANSELC, ANSC7, BANKED ; Enable digital RC7 for RX(1) #endif #endif #else banksel ANCON2 bcf ANCON2, ANSEL18, BANKED ; Enable digital RG2 for RX2 #endif Funny thing is that databook is totally misleading: "In order to configure these pins as an EUSART: ... For EUSART2: ... TRISG<1> bit must be cleared (= 0) for Asynchronous ..." Not true, and they admit it almost immediately. ;-) "Note: The EUSART control will automatically reconfigure the pin from input to output as needed." That's true, but it won't reconfigure this pin from analog to digital, and it is nowhere mentioned in UART chapter that you shoud do it. Mikael, give me your address so I can send you a PCB with 18F66K22 (or 65K90 if you prefer). It is pretty weird that I'm the only one in the whole world using this with FF, hope somebody else will join and find more use for all this. Zdravko |