Forum > Embedded

Smallest/lightest FPC capable processor?

<< < (2/7) > >>

d.ioannidis:
Hi,

  an atmega avr could do the job easily.

  You can have an RTC also if you can solder, and make the circuit in a zero/veroboard pcb, running at 4MHz. Of course you'll need a programmer but you can use an arduino uno / mini nano for that task or buy a USBasp or USBisp which are very cheap ;).

regards,

marcov:

--- Quote from: MarkMLl on August 03, 2022, 11:32:56 am ---I've also got various AVR boards where I've upgraded the loader so that it retains the cause of the last reset, which can be read via a C++ variable. However I don't know whether FPC has the capability of declaring that a (global) variable should retain its value rather than being initialised at startup.

--- End quote ---

(From similar functionality with dspics, I'd say that is a implementation specific attribute. FPC supports generic attributes, but what they do (placement in a block that isn't zeroed on startup) still will have to implemented)

MarkMLl:

--- Quote from: marcov on August 03, 2022, 11:53:17 am ---
--- Quote from: MarkMLl on August 03, 2022, 11:32:56 am ---I've also got various AVR boards where I've upgraded the loader so that it retains the cause of the last reset, which can be read via a C++ variable. However I don't know whether FPC has the capability of declaring that a (global) variable should retain its value rather than being initialised at startup.

--- End quote ---

(From similar functionality with dspics, I'd say that is a implementation specific attribute. FPC supports generic attributes, but what they do (placement in a block that isn't zeroed on startup) still will have to implemented)

--- End quote ---

(Skipping the "TBD" bit): yes, agreed. Looking at my notes, the AVR format is


--- Code: C  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---/* * If possible, retrieve the reset reason. On an Arduino, Optiboot >=4.6 will save  * this into r2 and then clear MCUSR, other architectures might have something * similar. In all cases assume that interpretation of the value is target-specific, * but on an AVR are likely to be some combination of *  *      0x10  JTAG reset *      0x08  Watchdog reset *      0x04  Brownout reset *      0x02  External (button) reset *      0x01  Power-on reset */unsigned char _reset_reason __attribute__ ((section (".noinit"))); void getMCUSR(void) __attribute__((naked)) __attribute__((section(".init0"))); void getMCUSR(void){   __asm__ __volatile__ ( "mov %0, r2 \n" : "=r" (_reset_reason) : );}  /* This needs a runtime test that Optiboot is at at least version 4.6. If not * valid then as a side-effect the saved reason will be set to an "impossible" * value. */bool trustResetReason(void) {  if (pgm_read_word(0xfffe) >= 0x0406)    return true;  else {    _reset_reason = 0xff; // Not a valid combination    return false;  }  } ...       if (trustResetReason()) { // Needs runtime test against Optiboot version.        Serial.print(FF(" Reset: 0x"));        board_info_hex2(_reset_reason);      }   
However, I think the bigger point here is that the broader community has organised things such that this sort of thing can be done fairly painlessly on an AVR. They've also arranged things such that PIO programming can be done close to (if not interleaved with) the C++ on an RP2040, while my understanding is that the best that FPC can offer is "stick it into a resource and call the preprocessor using Lazarus" (which is also what we're told is an adequate alternative to embedding SQL blocks in Pascal).

MarkMLl

ccrause:

--- Quote from: MarkMLl on August 03, 2022, 12:16:19 pm ---
--- Quote from: marcov on August 03, 2022, 11:53:17 am ---
--- Quote from: MarkMLl on August 03, 2022, 11:32:56 am ---I've also got various AVR boards where I've upgraded the loader so that it retains the cause of the last reset, which can be read via a C++ variable. However I don't know whether FPC has the capability of declaring that a (global) variable should retain its value rather than being initialised at startup.

--- End quote ---

(From similar functionality with dspics, I'd say that is a implementation specific attribute. FPC supports generic attributes, but what they do (placement in a block that isn't zeroed on startup) still will have to implemented)

--- End quote ---

(Skipping the "TBD" bit): yes, agreed. Looking at my notes, the AVR format is


--- Code: C  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---/* * If possible, retrieve the reset reason. On an Arduino, Optiboot >=4.6 will save  * this into r2 and then clear MCUSR, other architectures might have something * similar. In all cases assume that interpretation of the value is target-specific, * but on an AVR are likely to be some combination of *  *      0x10  JTAG reset *      0x08  Watchdog reset *      0x04  Brownout reset *      0x02  External (button) reset *      0x01  Power-on reset */unsigned char _reset_reason __attribute__ ((section (".noinit"))); void getMCUSR(void) __attribute__((naked)) __attribute__((section(".init0"))); void getMCUSR(void){   __asm__ __volatile__ ( "mov %0, r2 \n" : "=r" (_reset_reason) : );}  /* This needs a runtime test that Optiboot is at at least version 4.6. If not * valid then as a side-effect the saved reason will be set to an "impossible" * value. */bool trustResetReason(void) {  if (pgm_read_word(0xfffe) >= 0x0406)    return true;  else {    _reset_reason = 0xff; // Not a valid combination    return false;  }  } ...       if (trustResetReason()) { // Needs runtime test against Optiboot version.        Serial.print(FF(" Reset: 0x"));        board_info_hex2(_reset_reason);      }   
However, I think the bigger point here is that the broader community has organised things such that this sort of thing can be done fairly painlessly on an AVR. They've also arranged things such that PIO programming can be done close to (if not interleaved with) the C++ on an RP2040, while my understanding is that the best that FPC can offer is "stick it into a resource and call the preprocessor using Lazarus" (which is also what we're told is an adequate alternative to embedding SQL blocks in Pascal).

MarkMLl

--- End quote ---

I think this conversation is drifting away from the OP, but anyway, here is the FPC way (putting code in a section requires main version for now):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  resetReason: byte; section '.noinit'; procedure getMCUSR; assembler; noreturn; section '.init1';asm  sts resetReason, r2end; begin  Halt(resetReason);end. 

d.ioannidis:
Hi,


--- Quote from: ccrause on August 03, 2022, 01:22:15 pm ---I think this conversation is drifting away from the OP, but anyway, here is the FPC way (putting code in a section requires main version for now):

--- End quote ---

 I remembered seeing this here https://github.com/ccrause/freepascal/wiki/Better-support-for-address-spaces-in-FPC#section-support-for-procedures

 Maybe it should be in fpc avr wiki ?

regards,

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version