Giter VIP home page Giter VIP logo

Comments (4)

nicocvn avatar nicocvn commented on June 1, 2024 1

And possibly the issue might be the offset of the register:

struct Peripheral {
  struct bxCAN : RegisterPack<0x4000'6400, 1024> {
    // Filter initialization mode
    // When defining the PackedRegister the offset must be in bits! so (0x200)*8 = 4096
    using FINIT =
        Field<PackedRegister<bxCAN, RegBitSize::b32, 4096>, 32, 0, read_write>;
  };
};

Let me know if that helps.

from cppreg.

nicocvn avatar nicocvn commented on June 1, 2024

I do not have experience with that particular MCU so let me ask a few generic questions :)

  • Which compiler are you using?

  • The cppreg version of your snippet would look like:

    void can_t::init_filters_() {
      Peripheral::bxCAN::FINIT::set();
      
      // ... magic ...
    
      // Turn all filters initialization -> active
      Peripheral::bxCAN::FINIT::clear();
      while ( Peripheral::bxCAN::FINIT::is_set()) __nop();
    }

    right?

  • Any chances you can isolate the generated assembly listing?


Could you try the following and see if that works:

struct Peripheral {
  struct bxCAN : RegisterPack<0x4000'6400, 1024> {
    // Filter initialization mode
    using FINIT =
        Field<PackedRegister<bxCAN, RegBitSize::b32, 0x200>, 32, 0, read_write>;
   constexpr static auto active_mode = FINIT::type{0x2A1C0E00};
   constexpr static auto initialization_mode = FINIT::type{0x2A1C0E01};
  };
};

// ...

void can_t::init_filters_() {
  Peripheral::bxCAN::FINIT::write<Peripheral::bxCAN::initialization_mode>();
  
  // ... magic ...

  // Turn all filters initialization -> active
  Peripheral::bxCAN::FINIT::write<Peripheral::bxCAN::active_mode>();
  while (Peripheral::bxCAN::FINIT::read() != Peripheral::bxCAN::active_mode) __nop();
}

from cppreg.

nicocvn avatar nicocvn commented on June 1, 2024

Mind the typo in the last snippet ... FINIT should be:

// width is 1 bit not 32.
using FINIT =
        Field<PackedRegister<bxCAN, RegBitSize::b32, 4096>, 1, 0, read_write>;

from cppreg.

arturvasilev avatar arturvasilev commented on June 1, 2024
// When defining the PackedRegister the offset must be in bits! so (0x200)*8 = 4096

Oh, my! That was it! My eyes blurred after 78 PackedRegister -- and couldn't see that obvious error of mine! >_<

Thanks for pointing that out!

I should consider a vacation sooner, than later. :-)

Issue closed! Thanks for helping!

from cppreg.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.