How Connecting dos devices USART one 2EUSART Pic multiplexed.

Başlatan buntger, 12 Eylül 2013, 09:10:23

buntger

Hello,
I added the ports manipulation command "TRISA" and I do not work.
I do not know what to do ...

'PORTA.0 = Input
'PORTA.1 = Output

TRISA =% 00000001

''''''''''''' ALL CODE ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Device = 18F46J50      'PIC Selection
Declare Xtal 12        'FIX XTAL to 12Mhz

Config_Start          'Fuses
WDTEN = OFF ;Disabled - Controlled by SWDTEN bit
PLLDIV = 3 ;Divide by 3 (12 MHz oscillator input)
STVREN = On ;Enabled
XINST = OFF ;Enabled Extended intruction disable
Debug = OFF ;Disabled
CPUDIV = OSC1
CP0 = OFF ;Program memory is not code-protected
OSC = HS 'HSPLL ;HS+PLL, USB-HS+PLL
T1DIG = On ;Secondary Oscillator clock source may be selected
LPT1OSC = OFF ;High-power operation
FCMEN = OFF ;Disabled  fail-safe clock monitor
IESO = On ;Enabled   'two-speed start-up
Config_End

Dim Var1 As Byte

'Declarations EUSART2
Declare Hserial2_Baud  = 9600       
Declare Hserial2_RCSTA = %10010000 
Declare Hserial2_TXSTA = %00100100 
Declare Hserial2_SPBRG = 77   
Declare Hserial2_Clear = On 

Declare All_Digital = True
TRISA = %00000001


;*************************************
; Unlock Registers
;*************************************
; PPS registers are in BANK 14
Movlb 0x0E
Bcf INTCON, GIE ; Disable interrupts
; for unlock sequence
Movlw 0x55
Movwf EECON2, 0
Movlw 0xAA
Movwf EECON2, 0
; Turn off PPS Write Protect
Bcf PPSCON, IOLOCK, BANKED
;***************************
; Assign RX2 To Pin RP0=PORTA.0
;***************************
Movlw 0x00                                                'OK?  <-----------------
Movwf RPINR16, BANKED                            'OK?  <-----------------
;***************************
; Assign TX2 To Pin RP1=PORTA.5
;***************************
Movlw 0x05                                               'OK?  <-----------------
Movwf RPOR1, BANKED                              'OK?  <-----------------
;*************************************
; Lock Registers
;*************************************
Movlw 0x55
Movwf EECON2, 0
Movlw 0xAA
Movwf EECON2, 0
; Write Protect PPS (if desired)
Bsf PPSCON, IOLOCK, BANKED
'EndAsm


Loop:
HSerIn2 1000, Timeout, [Var1] ' Receive a byte serially into Var1
   Print Dec Var1, " " ' Display the byte received
GoTo Loop ' Loop forever

Timeout:
Cls
Print "Timed Out" ' Display an error if Hserin2 timed out
DelayMS 500
Stop

End

buntger

Hello,
I've added this Fuse "IOL1WAY" but .. does not work.

Config_Start          'Fuses para el programador QL-2006(MCU ELECTRONICS)
WDTEN = OFF ;Disabled - Controlled by SWDTEN bit
PLLDIV = 3 ;Divide by 3 (12 MHz oscillator input)
STVREN = On ;Enabled
XINST = OFF ;Enabled Extended intruction disable
Debug = OFF ;Disabled
CPUDIV = OSC1
CP0 = OFF ;Program memory is not code-protected
OSC = HS 'HSPLL ;HS+PLL, USB-HS+PLL
T1DIG = On ;Secondary Oscillator clock source may be selected
LPT1OSC = OFF ;High-power operation
FCMEN = OFF ;Disabled  fail-safe clock monitor
IESO = On ;Enabled   'two-speed start-up
WDTPS = 32768 ;1:32768
DSWDTOSC = INTOSCREF ;DSWDT uses INTRC
RTCOSC = T1OSCREF ;RTCC uses T1OSC/T1CKI
DSBOREN = On ;Enabled
DSWDTEN = OFF ;Watch Dog
DSWDTPS = G2 ;1:2,147,483,648 (25.7 days)
MSSP7B_EN = MSK7 ;7 Bit address masking mode
IOL1WAY = OFF ;The IOLOCK bit (PPSCON<0>) can be set once              <----------------------- ADD
Config_End

buntger

Hello,
Attempting to operate the 2 Euart the PIC18F46J50. I removed the ASM code for a similar but does not work.
I need your helpThank you ..

This is the New Code.

Code:
Device = 18F46J50      'PIC Selection
Declare Xtal 12        'FIX XTAL to 12Mhz

Config_Start          'Fuses
 WDTEN = OFF ;Disabled - Controlled by SWDTEN bit
 PLLDIV = 3 ;Divide by 3 (12 MHz oscillator input)
 STVREN = On ;Enabled
 XINST = OFF ;Enabled Extended intruction disable
 Debug = OFF ;Disabled
 CPUDIV = OSC1 ;No CPU system clock divide
 CP0 = OFF ;Program memory is not code-protected
 OSC = HS 'HSPLL ;HS+PLL, USB-HS+PLL
 T1DIG = On ;Secondary Oscillator clock source may be selected
 LPT1OSC = OFF ;High-power operation
 FCMEN = OFF ;Disabled  fail-safe clock monitor
 IESO = On ;Enabled   'two-speed start-up
 WDTPS = 32768 ;1:32768
 DSWDTOSC = INTOSCREF ;DSWDT uses INTRC
 RTCOSC = T1OSCREF ;RTCC uses T1OSC/T1CKI
 DSBOREN = On ;Enabled
 DSWDTEN = OFF ;Watch Dog
 DSWDTPS = G2 ;1:2,147,483,648 (25.7 days)
 IOL1WAY = OFF ;The IOLOCK bit (PPSCON<0>) can be set once
' MSSP7B_EN = MSK7 ;7 Bit address masking mode
'WPFP = PAGE_63 ;Write Protect Program Flash Page 63
' WPEND = PAGE_WPFP ;Page WPFP<5:0> through Configuration Words erase/write protected
 WPCFG = OFF ;Configuration Words page not erase/write-protected
 WPDIS = OFF ;WPFP<5:0>/WPEND region ignored 
Config_End
 
'Declarations EUSART2
Declare Hserial2_Baud  = 9600       'Set baud rate to 9600
Declare Hserial2_RCSTA = %10010000  'Enable serial port and continuous receive
Declare Hserial2_TXSTA = %00100100  'Enable transmit and asynchronous mode
Declare Hserial2_SPBRG = 77         'Set SPBRG for 12Mhz Xtal
Declare Hserial2_Clear = On         'Optionally clear the buffer before receiving

Declare All_Digital = True    'PortA all Digital
Dim Var1 As Byte

'Configuring USART2
Dim IOLOCK As PPSCON.0
Dim INTCON_GIE As INTCON.7 'global interrupt disable bit (GIEH)
Dim t_gie As Bit           'saved GEIH state

t_gie = 0

t_gie = INTCON_GIE    'save current state of GIE intr bit and disable interrupts
INTCON_GIE = 0
'Unlock PPS configuration
EECON2 = $55         'send sequence to unlock the PPS configuration
EECON2 = $AA
IOLOCK = 0
'Mapping Ports
PPSCON.0=0    'Turn off PPS Write Protect 0
RPINR16=0     'PortA.0= RX2  Mapping Port
RPOR1=5       'PortA.1= TX2  Mapping Port
'Lock PPS configuration
EECON2 = $55
EECON2 = $AA
IOLOCK = 1
If t_gie = 1 Then INTCON_GIE = 1

Loop:
HSerIn2 1000, Timeout, [Var1] ' Receive a byte serially into Var1
   Print Dec Var1, " " ' Display the byte received
GoTo Loop ' Loop forever

Timeout:
Cls
Print "Timed Out" ' Display an error if Hserin2 timed out
DelayMS 500
Stop

End



THX.