Author Topic: what arithmetic functions need to be made in hardware?  (Read 7634 times)

0 Members and 1 Guest are viewing this topic.

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: what arithmetic functions need to be made in hardware?
« Reply #25 on: September 18, 2016, 06:05:24 pm »
It's a bit of a swine if you're writing code in a high level language, though, where you don't know the exact length of the object code in advance.

How many instructions do I need to disable interrupts for? Answers on a postcard...

usually you need to disable interrupt in "critical sections", which are written in assembly
and here we go with that idea

you have the same problem if you have to set a bit in your instruction opcode
in order to make it "interrupt disabled during execution" (IDDE)
you need a pragma, or a way, to tell the compiler to set the IDDE-bit  :-//
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4228
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: what arithmetic functions need to be made in hardware?
« Reply #26 on: September 18, 2016, 06:24:17 pm »
I agree about the pragma.

A 'critical' section doesn't need to be in assembler, though. Something like a read / modify / write, or sending an unlock sequence to a peripheral, doesn't necessarily need to be fast but it does need to be uninterrupted.

The PIC24 architecture is particularly bad for needing specific assembly language instructions to achieve ordinary objectives. Simply reading from Flash requires 'table read' instructions to be used, which are included as built-in macros by the XC16 compiler, but the result is messy. It also means a function to, say, print a string located in RAM can't be the same as a function to print a string constant from Flash.

Writing to the register that governs the clock source is a pain too, because it requires a sequence of writes to be done not just one after the other, but actually on consecutive clock edges. This again is handled by a built-in macro, but it's a pointless restriction that doesn't really help anybody.

Offline mac.6

  • Regular Contributor
  • *
  • Posts: 225
  • Country: fr
Re: what arithmetic functions need to be made in hardware?
« Reply #27 on: September 18, 2016, 07:09:37 pm »
Turbo DMA: DMA engine that apply transfert function like FFT/DCT while moving data between memory location or from/to devices.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: what arithmetic functions need to be made in hardware?
« Reply #28 on: September 19, 2016, 03:22:06 pm »
It's a bit of a swine if you're writing code in a high level language, though, where you don't know the exact length of the object code in advance.

How many instructions do I need to disable interrupts for? Answers on a postcard...

For the PIC24F the parameter value of the idis can be 0x3fff ie. 16384 cycles. So, one can use idis #0x3fff at the start of the block and idis #0 at the end of the block. If one needs to disable the interrupts for more than few tens of cycles for the atomic operation, then one should consider alternative solution to the problem.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf