P24FJ64GA002 and Config words programming problem - solved

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

P24FJ64GA002 and Config words programming problem - solved

#1 Post by Dany » 19 May 2011 21:20

Latest news: seems to be a problem with the "IOL1Way" configuration bit, see http://www.mikroe.com/forum/viewtopic.p ... 03&start=7

Hi all,

I am starting to use the P24F PIC series (P24FJ64GA002) and my second try project gives me already a problem :? . In this project I try to make Uart1 send something. The main change for me is that the P24F has peripheral pin select registers, also for Uart1.
I think I have done everything well, but it does not work, I do not get a Uart TX signal on the TX pin chosen. :?

Here is the code.
I did check the contents of RPINR18 (for the selection of the Uart1 input pin), and RPOR7 (for the selection of the Uart output pin) and the values are OK. I do not know if the line "UART_Set_Active(..)" is necessary, but with or without it, it does not work.
Anyway, the led in the while true loop blinks at the correct frequency... :D, so I know the program is running.

Again I am conviced it is a stupid oversight error (as usual...) of me...


If anyone can help, thanks in advance! :D :D

Code: Select all

program Uart_Test;

{ Declarations section }

var Res: word;

begin
  { Main program }
  
  //ADPCFG := 0xFFFF;       // Configure AN pins as digital I/O
  AD1PCFG := $ffff;

  TrisA.0 := 0; //Led
  LatA.0 := 0;
  
  TrisB.15 := 0;  // Uart output --> see post of jpc below
  TrisB.14 := 1;  // Uart input  --> see post of jpc below
  
  // Unlock_IOLOCK; --> see post of jpc below
  Res := PPS_Mapping (14, _INPUT, _U1RX);   // RP14 is uart1 input  (pin 25)
  Res := PPS_Mapping (15, _OUTPUT, _U1TX);  // RP15 is uart1 output (pin 26)
  // Lock_IOLOCK; --> see post of jpc below
  
  Res := U1Mode; // for test purposes
  Res := U1Sta;  // for test purposes
  
  Res := RPINR18; // for test purposes
  Res := RPOR7;   // for test purposes
  
  Uart1_Init(9600);
  Delay_ms(250);
  UART_Set_Active(@UART1_Read, @UART1_Write, @UART1_Data_Ready, @UART1_Tx_Idle); // set UART1 active
  
  Res := U1Mode;  // for test purposes
  Res := U1Sta;   // for test purposes
  
  Res := RPINR18; // for test purposes
  Res := RPOR7;   // for test purposes
  
  while true do
  begin
    LatA.0 := 1;   // Led
    UART1_Write_Text('Test');
    Uart1_Write(#13);
    Uart1_Write(#10);
    delay_ms(250);
    LatA.0 := 0;  // Led
    delay_ms(250);
  end;

end.


Here are the project settings (I use a 8Mhz crystal to have a 32 Mhz MCU clock):
Image
Image
Last edited by Dany on 02 Aug 2011 12:07, edited 8 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: P24FJ64GA002 and Uart problems

#2 Post by jpc » 20 May 2011 07:36

first thing to do is to set the tris-bit of the assigned tx-pin to output, i have doubts this is done by the uartx_init. As such the IOLocking is done by the pps_mapping ( unfortunately btw) so you do not need that.
Au royaume des aveugles, les borgnes sont rois.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Uart problems

#3 Post by Dany » 20 May 2011 09:39

jpc wrote:first thing to do is to set the tris-bit of the assigned tx-pin to output, i have doubts this is done by the uartx_init. As such the IOLocking is done by the pps_mapping ( unfortunately btw) so you do not need that.
Thanks Jpc.

I added the initialisation of the tris bits as you suggested (the source code in the first post is also adapted), but still no success! :?

Code: Select all

  TrisB.15 := 0;  // Uart output
  TrisB.14 := 1;  // Uart input
I also left out the IO unlocking/locking.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Uart problems

#4 Post by Dany » 21 May 2011 19:22

Hi, I found a way to make it work :D :D, I fill the peripheral remappable pin regsiters myself :

Code: Select all

  Unlock_IOLOCK;
  RPINR18 := $000E; // U1Rx is RP14
  RPOR7   := $0300; // Rp15 is function 3 (U1TX)
  Lock_IOLOCK;
is actually connecting the uart output to Rp15.

This code does not do that apparently (it does not work):

Code: Select all

  Res := PPS_Mapping (14, _INPUT, _U1RX);   // RP14 is uart1 input  (pin 25)
  Res := PPS_Mapping (15, _OUTPUT, _U1TX);  // RP15 is uart1 output (pin 26)
I think the latter code should do exactly the same as the first (working) piece of code.
What is odd: in the software debugger the values are Ok, but when the program is actually running in the PIC, the values are wrong. :?

Is this my misunderstanding or is it a library problem?

Thanks in advance!

p.s. Thanks jpc and Hans (via private mail) for your help! :D :D
Last edited by Dany on 21 May 2011 19:51, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Uart problems

#5 Post by Dany » 21 May 2011 19:45

Hi, I am a little further now:

The statement

Code: Select all

Res := PPS_Mapping (15, _OUTPUT, _U1TX);  // RP15 is uart1 output (pin 26)
does its work as it should, but as soon as I execute also

Code: Select all

Res := PPS_Mapping (14, _INPUT, _U1RX);   // RP14 is uart1 input  (pin 25)
all uart communication stops (also uart output -- U1TX --). This statement is the cause of the problem.

furthermore, once the latter code blocked the Uart, it can not be corrected with

Code: Select all

RPINR18 := $000E; // U1Rx is RP14
any more, the Uart1 stays dead... :?

Strange... :shock:
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Uart problems

#6 Post by Dany » 22 May 2011 18:35

Hi, this issue is partly solved in v4.80 bèta!

The Uart is capable to send now :D , but reception is still not working :? . Both sending and receiving are working if I do fill in RPINR18 and RPOR7!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Uart problems

#7 Post by Dany » 23 May 2011 07:48

Hi, I was a little bit too fast to cheer, see the previous post (edited). :?
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Uart problems

#8 Post by Dany » 23 May 2011 12:32

Hi,

There seems to be a problem with the "IOL1Way" configuration bit. The PIC acts as if it was set, it allows only one IO Unlock/Lock sequence:

This code works:

Code: Select all

  Unlock_IOLOCK;
  RPINR18 := $000E; // U1Rx is RP14
  RPOR7   := $0300; // Rp15 is function 3 (U1TX)
  Lock_IOLOCK;
This code does not work:

Code: Select all

  Unlock_IOLOCK;
  RPINR18 := $000E; // U1Rx is RP14
  Lock_IOLOCK;
  
  Unlock_IOLOCK;
  RPOR7   := $0300; // Rp15 is function 3 (U1TX)
  Lock_IOLOCK;
This is most probably also the reason why a sequence of 2 "pps_mapping" calls does not work: it needs 2 unlock/lock activities.

Anyway,
I do set the "IOL1Way" configuration bit to zero, and when programming (or after a "reload hex") I can see in the mikroProg suite the config bit saying:
The OSCCON <IOLOCK> bit can be set and cleared as needed.
:D
But... When I read code back from the PIC with the mikroProg suite it says:
The OSCCON <IOLOCK> bit can be set only once.
:?

A "verify" with the mikroprog suite however says "no differences". :?:


A thing I do not understand is the content of the .hex file concerning the config words:
:02 0000 04 0001 F9
:08 57F8 00 AEFB00007F3F0000 42
:00 0000 01 FF
I do recognise the values for the config words (which are $FBAE and $3F7F), but I do not recognise the address ($57F8). According the datasheet this should be $ABFC for a P24FJ64A002. :?: :?:

Even the "04" field in front of it (extended addressing) gives no sensible address if added after shifting 4 bits to the left.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: P24FJ64GA002 and Config words programming problem

#9 Post by slavisa.zlatanovic » 26 May 2011 15:34

Hi Dany!

I've already contacted you regarding this issue at the support ticked you opened.
I've reproduced this issue and I'll contact you as soon as we provide a solution to your problem.
Sorry for the inconvenience.
Best regards
Slavisa

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Config words programming problem

#10 Post by Dany » 26 May 2011 18:14

slavisa.zlatanovic wrote:Hi Dany!

I've already contacted you regarding this issue at the support ticked you opened.
I've reproduced this issue and I'll contact you as soon as we provide a solution to your problem.
Sorry for the inconvenience.
Thanks! :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: P24FJ64GA002 and Config words programming problem

#11 Post by slavisa.zlatanovic » 27 May 2011 09:43

Hi!

Please, check out your Support Ticket. I've attached there the mikroProg Suite For PIC.exe with the bug fixed.
It is soon going to be available for download for all users.
Best regards
Slavisa

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Config words programming problem

#12 Post by Dany » 27 May 2011 09:58

slavisa.zlatanovic wrote:Hi!

Please, check out your Support Ticket. I've attached there the mikroProg Suite For PIC.exe with the bug fixed.
It is soon going to be available for download for all users.
Thanks! :D :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Config words programming problem

#13 Post by Dany » 29 Jul 2011 13:25

slavisa.zlatanovic wrote:Hi!
Please, check out your Support Ticket. I've attached there the mikroProg Suite For PIC.exe with the bug fixed.
It is soon going to be available for download for all users.
Hi, the intermediate version you sent works fine!
I see with the mP v5.01 version that there is a mikroProg Suite v2.10. Is the problem also solved in that version please?
Thanks in advance!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: P24FJ64GA002 and Config words programming problem

#14 Post by filip » 01 Aug 2011 09:43

Hi,

This should have been fixed in the 2.10 version also.

Regards,
Filip.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P24FJ64GA002 and Config words programming problem

#15 Post by Dany » 02 Aug 2011 12:06

filip wrote:Hi,

This should have been fixed in the 2.10 version also.

Regards,
Filip.
It is indeed. Thanks! :D :D :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”