Author Topic: what is the point of a debugger if it does not tell me I cannot have that  (Read 4011 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18210
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Of course searching for anything on the microchip website is totally hopeless, the search feature refuses to get series names and will only find results when a precise part number is entered.
 

Offline errorprone

  • Contributor
  • Posts: 39
I’ve found microchip maps better than their normal website for search.  https://www.microchip.com/maps/Microcontroller.aspx
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4402
  • Country: us
Quote
Some Cortex-M3 and M4 chips implement bit-banding. This eliminates the need for RMW cycle.
That doesn't change the basic timing I described.  If you use a chip with neither bit-banding NOR set/clear registers for GPIO, you can add at least one more instruction to read the old port register contents (and probably another one or or/and your bit with the read contents.)

SAMC has set/clear/toggle GPIO registers, and IOBUS, so that's the way to go if you're looking for maximum performance.

ARM Microcontrollers from vendors with half-a-clue almost always have the set/clear GPIO registers.



 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 887
Quote
That doesn't change the basic timing I described.
That seems to be something that gets overlooked- any method requires getting a value into a some register, which does not happen on its own (needs instructions to setup).

Although the set/clr/tgl registers can speed things up due to assignment-only use, their main purpose is to keep the bit manipulation atomic. The sam has these registers, which allow any code (+interrupts) to manipulate pins without the need for all code to protect the bit manipulation (since pin register bits of a port typically live inside the same register). The iobus in this case is for speed, the set/clr/tgl is for atomicity.

The port registers are usually somewhat unique in that various pieces of code can be manipulating pins which typically share a register. The addition of set/clr/tgl registers eliminate the need to interrupt protect each use. There are other pin properties that may share registers on some mcu's, such as an stm32 which cannot change a pins properties atomically (so if you manipulate these property registers the safe thing to do is interrupt protect them).

For a SAM, I believe the only port registers to otherwise worry about are the pmux registers (8bit register, shared by 2 pins), but there is a wrconfig register that can take care of dealing with pmux in an atomic way. An EFR32/EFM32 has set/clr/tgl for all peripheral registers so is easy to do any register writing atomically (whether needed or not). A Renesas RA has a set/reset port register but they also have a single PFS register for each pin that contains most of its properties/state so any manipulation is isolated to a single pin and becomes similar to the typical peripheral register (no need to protect). The Renesas library uses the PFS register for pin writes, so is rmw but no other pin is affected (they seem to only use the set/reset register for writes to multiple pins).
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4402
  • Country: us
Quote
the set/clr/tgl is for atomicity. [rather than speed]
They certainly help with speed as well, ESPECIALLY if you need to ensure atomicity!  (None of the instruction sequences mentioned includes any additional atomicity handling, although it's inherent if you have either bit banding or set/clr/tgl.)


One thing I don't see taken advantage of very often is that some chips (including SAMC, I think) have byte-addressable GPIO peripheral registers, even though the ports themselves are wider.  Theoretically, this could save a bit if you're using the high bits in a port, since you can always "MOV" an 8bit constant, but getting things in the upper bits is more expensive.  (Alas, the provided .h files don't define byte-wide access to the ports.)


 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18210
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Yes I had considered adapting my text screen code to work across an 8 bit "port" rather than do each bit in turn. Does mean I'd have te be careful about pin multiplexing so not bothered so far.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4402
  • Country: us
Quote
I'd have te be careful about pin multiplexing
SAM microcontrollers do not seem to be very good at making available consecutive bits of IO ports.
I specifically complained about SAMD10 (etc) here: https://forum.microchip.com/s/topic/a5C3l000000UdT7EAK/t164828
(There are no 8bit ports with 8 consecutive pins.)


The RPi Pico folks implemented a neat way to set bit-fields in a port without affecting pins that belong to "something else", using a read/xor/toggle: https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_gpio/include/hardware/gpio.h#L718 (which should work on any device with a "toggle" capability.)
« Last Edit: August 12, 2023, 07:30:42 pm by westfw »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf