UART_Remappable_Init

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
RichardHirst
Posts: 35
Joined: 08 Feb 2007 11:25

UART_Remappable_Init

#1 Post by RichardHirst » 24 Feb 2010 22:19

Hi.

UART_Remappable_Init(19200)

The compile reports an error "223 304 Syntax error: Expected ")" but "19200" found"

Any surgestions please

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

Re: UART_Remappable_Init

#2 Post by Bytex » 25 Feb 2010 01:19

Hello.

I think
UART_Remappable_Init(19200)
is your own function or... where did you get it ? That's no MikroBasic function.

Could you please show us the code ?
Thanks.

Best regards,
Max

http://www.b-vu.com

RichardHirst
Posts: 35
Joined: 08 Feb 2007 11:25

Re: UART_Remappable_Init

#3 Post by RichardHirst » 25 Feb 2010 01:55

Hi Max

This is a built in UART Remappable Libraryfor the PIC 18F45J11

Library Routines
UART_Remappable_Init
UART_Remappable_Data_Ready
UART_Remappable_Tx_Idle
UART_Remappable_Read
UART_Remappable_Read_Text
UART_Remappable_Write
UART_Remappable_Write_Text

Jack Flanders
Posts: 337
Joined: 17 Apr 2008 02:53
Location: Fantasy Land

Re: UART_Remappable_Init

#4 Post by Jack Flanders » 25 Feb 2010 04:19

What happens if you comment out that line? Does it still give an error or does it compile ok?

RichardHirst
Posts: 35
Joined: 08 Feb 2007 11:25

Re: UART_Remappable_Init

#5 Post by RichardHirst » 25 Feb 2010 05:33

Yes if you delete the value in the Brackets, 19200 is does compile but has no Output on the Uart2

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

Re: UART_Remappable_Init

#6 Post by Bytex » 25 Feb 2010 13:39

Hello.

I think it's a compiler bug

Code: Select all

    Unlock_IOLOCK
    PPS_Mapping(15, _INPUT, _RX2_DT2)   ' Sets pin 15 to be Input, and maps RX2/DT2 Input to it
    PPS_Mapping(5, _OUTPUT, _TX2_CK2)   ' Sets pin 5 to be Output, and maps EUSART2 Asynchronous Transmit/Synchronous
    Lock_IOLOCK

    UART_Remappable_Init()
This code works. But you cannot set the needed speed !! :shock:

Best regards,
Max

http://www.b-vu.com

RichardHirst
Posts: 35
Joined: 08 Feb 2007 11:25

Re: UART_Remappable_Init

#7 Post by RichardHirst » 25 Feb 2010 13:50

Thanks for the reply..

Would you know how to set the speed to 19200 or 9600.. Have you tried it on a chip.. I get no output...

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: UART_Remappable_Init

#8 Post by p.erasmus » 25 Feb 2010 14:08

Hi Richard

Yesterday and today we discovered 2 bugs in the compiler in the Forum
would you be so kind to report this to mE support
at this link
http://www.mikroe.com/en/support/
as it helps to get the bugs fixed
Please :(

Best regards

Peter
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: UART_Remappable_Init

#9 Post by tihomir.losic » 26 Feb 2010 18:31

RichardHirst wrote:Would you know how to set the speed to 19200 or 9600.. Have you tried it on a chip.. I get no output...
Hello,

please, use this way of workaround:
for the same PIC (PIC18F45J11):

1) replace

Code: Select all

UART_Remappable_Init
with

Code: Select all

UART1_Init(19200)
2) compile your project in release mode.
3) Start debugger (F9)
4) Run Dis-assembly mode (ALT + D)
5) Copy the first three lines of this piece of code:

Code: Select all

;UART.mbas,35 ::                 UART1_Init(19200)      ' Initialize UART module at 9600 bps
0x00D4        0x0E19              MOVLW       25
0x00D6        0x6EB0              MOVWF       SPBRG 
0x00D8        0x84AD              BSF         TXSTA, 2, 0
0x00DA        0xDFB9              RCALL       _UART1_Init
6) Now get back onto first task of this workaround and type following:

Code: Select all

asm
    MOVLW       25
    MOVWF       SPBRG
    BSF         TXSTA, 2, 0
end asm

UART_Remappable_Init()
Baud Rate Generator (BRG) - The BRG is a dedicated, 8-bit or 16-bit generator that supports both the Asynchronous and Synchronous modes of the EUSART.
The SPBRGHx:SPBRGx register pair controls the period of a free-running timer. In Asynchronous mode, bits, BRGH (TXSTAx<2>) and BRG16 (BAUDCONx<3>), also control the baud rate. In Synchronous mode, BRGH is ignored.
Please, look at: BAUD RATES FOR ASYNCHRONOUS MODES

I hope it will help to you.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

RichardHirst
Posts: 35
Joined: 08 Feb 2007 11:25

Re: UART_Remappable_Init

#10 Post by RichardHirst » 28 Feb 2010 23:43

Hi Losic

Thanks for the work around.. I still have no Uart2 output.

Unlock_IOLOCK()
PPS_Mapping(4, _INPUT, _RX2_DT2) ' Sets pin RP4 RB1 to be Input, and maps RX2/DT2 Input to it
PPS_Mapping(8, _OUTPUT, _TX2_CK2) ' Sets pin RP8 RB5 to be Output, and maps EUSART2 Asynchronous Output to it
Lock_IOLOCK()

asm
MOVLW 25
MOVWF SPBRG
BSF TXSTA, 2, 0
end asm
UART_Remappable_Init()


then call; UART_Remappable_Write(65)

have I missed something..?

Richard

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: UART_Remappable_Init

#11 Post by tihomir.losic » 01 Mar 2010 09:52

Hello Richard,

please, create your support ticket:
http://www.mikroe.com/en/support
and send me your complete project in order to inspect it.

Thanks.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

zerala
Posts: 1
Joined: 27 Mar 2012 03:19

Re: UART_Remappable_Init

#12 Post by zerala » 27 Mar 2012 03:37

Hi,

I had some problems with this too.

But I solved using:

asm{ //config 9600 bps at USART 2
MOVLW 129
MOVWF SPBRG2
BSF TXSTA2, 2, 0
}
UART_Remappable_Init();

The value "129" I got with the workaround. But it's important to set SPBRG2 and TXSTA2, to use the second USART.

Regards

Tiago Ribeiro
Posts: 4
Joined: 05 Nov 2013 12:37

Re: UART_Remappable_Init

#13 Post by Tiago Ribeiro » 20 Nov 2013 17:02

tihomir.losic wrote:
RichardHirst wrote:Would you know how to set the speed to 19200 or 9600.. Have you tried it on a chip.. I get no output...
Hello,

please, use this way of workaround:
for the same PIC (PIC18F45J11):

1) replace

Code: Select all

UART_Remappable_Init
with

Code: Select all

UART1_Init(19200)
2) compile your project in release mode.
3) Start debugger (F9)
4) Run Dis-assembly mode (ALT + D)
5) Copy the first three lines of this piece of code:

Code: Select all

;UART.mbas,35 ::                 UART1_Init(19200)      ' Initialize UART module at 9600 bps
0x00D4        0x0E19              MOVLW       25
0x00D6        0x6EB0              MOVWF       SPBRG 
0x00D8        0x84AD              BSF         TXSTA, 2, 0
0x00DA        0xDFB9              RCALL       _UART1_Init
6) Now get back onto first task of this workaround and type following:

Code: Select all

asm
    MOVLW       25
    MOVWF       SPBRG
    BSF         TXSTA, 2, 0
end asm

UART_Remappable_Init()
Baud Rate Generator (BRG) - The BRG is a dedicated, 8-bit or 16-bit generator that supports both the Asynchronous and Synchronous modes of the EUSART.
The SPBRGHx:SPBRGx register pair controls the period of a free-running timer. In Asynchronous mode, bits, BRGH (TXSTAx<2>) and BRG16 (BAUDCONx<3>), also control the baud rate. In Synchronous mode, BRGH is ignored.
Please, look at: BAUD RATES FOR ASYNCHRONOUS MODES

I hope it will help to you.

Best regards,

Losic Tihomir
thank you, very helpful..worked =D

Post Reply

Return to “mikroBasic PRO for PIC General”