Menu

Error while trying to compile for pic24

ronny suy
2024-03-06
2024-03-08
  • ronny suy

    ronny suy - 2024-03-06

    Hi ,
    I'm trying to compile FF for pic24 , and also have a lot of these errors : Error: non-constant expression in ".if" statement.
    What could be the cause of this ? I don't have a clue so far.

    I'm using the latest mplab x ide and xc16.
    Regards,
    Ronny

     
  • Mikael Nordman

    Mikael Nordman - 2024-03-06

    When you clone the repository , the project has as default a not supported chip. I need to fix that.
    Look in config.c and ff24.inc for supported chips. PIC24FJ128GB202 for example.

     
  • ronny suy

    ronny suy - 2024-03-07

    Hi Mikael ,
    I'm starting again with the new FF5 you uploaded today.
    I realy want to compile ff5 and using a pic24fj256ga705 as soldered on a curiousity board from farnell.
    I've set project configuration to this chip and using the xc compiler.
    Again lots of errors.
    The first is : ../src/ff24.inc:447: Error: can't open p24fj_ga_705.inc for reading
    I'm trying to locate this file at the moment ...
    Can you help me on this one to start with ?
    Regards,
    Ronny
    BTW : If we can solve together this issues then I will write a guide on how to compile for pic24 and you maybe can put it on the website .

     
  • Mikael Nordman

    Mikael Nordman - 2024-03-07

    I uploaded a fix for ff24.inc, it should reference p24fj_ga_config.inc.
    There you should change these lines.

    .equ USB_CDC, 0
    .equ OPERATOR_UART, 1 
    

    It runs in the simulator. But I do not know if it works on the hardware.
    At least you may need to adjust the UART pin settings.

    BR Mikael

     
  • Mikael Nordman

    Mikael Nordman - 2024-03-07

    In the simulator it seems the EEPROM emulation in flash is broken for the pic24fj256ga705.
    I'll check it.

     
  • ronny suy

    ronny suy - 2024-03-07

    OK thanks !
    I will update the changes and see how it goes.

     
  • ronny suy

    ronny suy - 2024-03-07

    Mikael ,
    It compiles now ! Hope you can find the flaw in the eeprom emulation in flash.
    Meanwhile I will try to figure out the pin mapping for uart1.

     
  • ronny suy

    ronny suy - 2024-03-07

    For the curiousity board RB0 for tx and RB1 for rx would be nice.

     
    • Mikael Nordman

      Mikael Nordman - 2024-03-07

      I think this should do it.

      .equ RPINR18VAL, 1           ; U1RXPIN RP1 
      .equ U1_RPO_REGISTER, RPOR0  ; RP0
      .equ U1_RPO_VALUE, 0x0003    ; UART1 TX on RP0 pin
      
       
  • Mikael Nordman

    Mikael Nordman - 2024-03-07

    I could not find a fault in the eeprom emulation code. Hopefully it is just a problem with with the simulator.

     
  • ronny suy

    ronny suy - 2024-03-07

    ok thanks ! I'm busy trying to understand the uart mapping , and I will flash the pic after that.
    Let you know how it goes.
    Greets ,
    Ronny

     
  • ronny suy

    ronny suy - 2024-03-08

    Hi Mikael ,

    Thanks for the uart code , missed it yesterday.
    I programmed the board and it works :-)
    Thanks again.
    One thing to mention : The baudrate should be 38400 , but it's 9600 !
    Thats exacly 1/4th. I think , and correct me if I'm wrong , that this could be due to the fact that you're using the fastrc oscillator without the pll. So the cpu frequency is 8Mhz instead of 32Mhz.
    The board has indeed no xtal connected , so frc is the best option , but why not using the pll to do a *4 . According to the datsheet it's possible.
    Kind regards,
    Ronny

     
    • Mikael Nordman

      Mikael Nordman - 2024-03-08

      Good to hear it works.

      Well, You can use the FRCPLL just by changing the configs.c. I change the config in various ways for testing and the uploaded configs are not always sane if I forget to check it.

      #pragma config FNOSC = FRCPLL
      

      You can also change FREQ_OSC to 8000000, then the 38400 baud rate should work using the FRC without the PLL.

      BR Mikael

       
  • ronny suy

    ronny suy - 2024-03-08

    Mikael,

    Adding the pragma changes the baudrate to 38400 as it should.
    Does this mean the cpu now effectively runs at 32Mhz ?
    Regards,
    Ronny

     
  • Mikael Nordman

    Mikael Nordman - 2024-03-08

    Yes. The CPU now runs at 32 MHz, 16 MIPS.

     
  • ronny suy

    ronny suy - 2024-03-08

    Great !!!

     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.