<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88645/how-to-generate-multiple-signals-with-timing-controls-nrf52840</link><description>Hi Nordic community 
 
 We have a custom IC to interface with the nRF52840 chip. We did testing for that IC with FPGA and the related control, clock signals are as shown in the figure below. The frequency of these signals when interfacing with nRF52840</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Jun 2022 14:49:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88645/how-to-generate-multiple-signals-with-timing-controls-nrf52840" /><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371468?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 14:49:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03198d1e-88f3-416c-8f9b-08b081d1f429</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;PWM 16MHz clock is synchronous to 64MHz clock since 16MHz is derived from the 64MHz with a /4 circuit. Timer can generate 4 simultaneous starts for all 4 PWM peripherals (12 channels) via PPI using a single timer using either 2 timer compare registers with a Fork for each or 4 timer compare registers without Forks; the compare registers (2 or 4) should all be set to the same value so the PWM channels start their waveforms synchronously. For best accuracy keep the HFCLK crystal running and use a timer not an RTC for synchronous start.&lt;/p&gt;
&lt;p&gt;I should add that you might be able to use normal mode instead of waveform mode for 1 or more PWMs if the associated pins only need to generate a continuous fixed clock signal which would give 4 output pins for those non-waveform PWMs. More info on sequence is required to comment further.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371414?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 12:54:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a00de425-a7da-4024-b2b3-49d3b1bdd7dc</guid><dc:creator>Kenneth</dc:creator><description>[quote user="xxb9075"]May I know the reason why we cannot perform XOR to OUT register?[/quote]
&lt;p&gt;I might misunderstood what you wanted to do here, it&amp;#39;s a normal register that control output level for all the pins on the entire port, so you can do whatever operation you like, but you will always control all the pins on the port every time you write to the register.&lt;/p&gt;
[quote user="xxb9075"]For PWM, If we use all 4 PWM instances then we can control 12 pins in waveform modes? Assume that&amp;#39;s enough for us, if there a way to sync the waveforms between different PWM instances?[/quote]
&lt;p&gt;Since you need 4PWM instances, the PPI will require 4 clock pulses (@64MHz) to start them all (e.g. from a timer compare event), however, since the GPIO peripheral is running internally on a 16MHz clock that run ascync to the 64MHz clock, I assume&amp;nbsp;some of the 4 PWM peripherals will be off by a 16MHz period.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371388?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 12:08:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3a49e5c-351b-4bd7-b44a-0eba37027f50</guid><dc:creator>xxb9075</dc:creator><description>&lt;p&gt;Thanks Kenneth,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s very helpful. To follow up:&lt;/p&gt;
&lt;p&gt;May I know the reason why we cannot perform XOR to OUT register?&lt;/p&gt;
&lt;p&gt;Would the implementation with nRF Connect SDK based on Zephyr be any different from the nRF5 SDK Softdevice approach? Based on your experience, what would be a safe application interrupt frequency if we use the softdevice.&lt;/p&gt;
&lt;p&gt;For PWM, If we use all 4 PWM instances then we can control 12 pins in waveform modes? Assume that&amp;#39;s enough for us, if there a way to sync the waveforms between different PWM instances?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371295?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 07:57:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:494c3951-7d2e-46d1-b54f-4102a22c602f</guid><dc:creator>Kenneth</dc:creator><description>[quote user="xxb9075"]Would you explain the interrupt latency table a little bit more?[/quote]
&lt;p&gt;These were only the interrupt latency delays, it does not include the time the softdevice may be executing code in a higher level interrupt, e.g. this is shown here:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_processor_avail_interrupt_latency/ble_peripheral_connection_performance.html"&gt;https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_processor_avail_interrupt_latency/ble_peripheral_connection_performance.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So you can&amp;#39;t just run the code at any time, you need to schedule this between BLE events.&lt;/p&gt;
[quote user="xxb9075"]And then for the strategy to generate these signals, OUTSET and OUTCLR are better than OUT because they will only alter pins that are specified?[/quote]
&lt;p&gt;Yes.&lt;/p&gt;
[quote user="xxb9075"]Would I be able to perform an XOR of OUT and 0xFFFFFFFF (the pins that need to be toggled are set to 1) to achieve the same goal?[/quote]
&lt;p&gt;No.&lt;/p&gt;
[quote user="xxb9075"]To generate the timing, what do you recommend if we can slow things down? Shall we use a timer to generate such interrupts and toggle OUT/OUTSET/OUTCLR in the ISR?[/quote]
&lt;p&gt;I don&amp;#39;t know, I think it can become very slow if you need to base this on a timer interrupt.&lt;/p&gt;
[quote user="hmolesworth"]Some of the signals look synchronous so it may be possible to use multiple PWMs each of which has up to 4 pins; waveform mode (3 pins per PWM) can be used to encode sequences without interrupts[/quote]
&lt;p&gt;A good point that PWM can be used, my worry though is the input pin that I assume might need to read during this sequence also, and that starting and stopping PWM (e.g. to updated the sequence) can also take a a few us.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371243?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 20:03:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02de0245-bdb2-4d33-9565-0b1c189a626c</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Some of the signals look synchronous so it may be possible to use multiple PWMs each of which has up to 4 pins; waveform mode (3 pins per PWM) can be used to encode sequences without interrupts, and maybe PPI for concatenation and/or links to timers. To comment further requires some details of the timing sequences&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371232?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 17:46:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e485c94f-1be8-4fb6-b445-bb0274d946ca</guid><dc:creator>xxb9075</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;Thanks for the response. It&amp;#39;s very helpful! May I ask a few more things if you don&amp;#39;t mind.&lt;/p&gt;
&lt;p&gt;Would you explain the interrupt latency table a little bit more? Let&amp;#39;s say if I want to use the BLE softdevice or implemented with nRF Connect SDK, given the interrupt latency requirement, because of the 4 us latency, look like I can only achieve 250 kHz frequency maximum?&lt;/p&gt;
&lt;p&gt;And then for the strategy to generate these signals, OUTSET and OUTCLR are better than OUT because they will only alter pins that are specified? Would I be able to perform an XOR of OUT and 0xFFFFFFFF (the pins that need to be toggled are set to 1) to achieve the same goal?&lt;/p&gt;
&lt;p&gt;To generate the timing, what do you recommend if we can slow things down? Shall we use a timer to generate such interrupts and toggle OUT/OUTSET/OUTCLR in the ISR?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371230?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 17:28:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d19180ae-207e-4dc2-b09e-24e107126586</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi Richard,&lt;/p&gt;
&lt;p&gt;Honestly I think this will be very difficult, from the &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/interrupt_latency_soc_framework.html"&gt;interrupt latency table&lt;/a&gt; you can see that it&amp;#39;s not possible to make this interrupt driven, so you will need to make this code run in a tight loop without any other interrupt or even softdevice that can interrupt the execution. If all pins are on the same PORT, you can control them all in one cycle by using the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html#register.OUT"&gt;OUT register&lt;/a&gt;, if you can allow a 16MHz clock cycles between the signals then you can use the OUTSET and OUTCLR registers after eachother instead (advantage:&amp;nbsp;you don&amp;#39;t set/clear pins that is not part of the parallell interface by using those two registers instead of OUT). But honestly speaking I think it&amp;#39;s going to be very tight, especially if you need to calculate the parallell output values during the tight timing.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371225?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 16:52:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0cabeed-3bfb-40ab-94d2-6decc61c7a0b</guid><dc:creator>xxb9075</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the response.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes you can say this is parallel interface. Not all signals must be in synchronization but some of them are, meaning some of the edges need to align.&lt;/p&gt;
&lt;p&gt;One pin will be input, others are all output.&lt;/p&gt;
&lt;p&gt;Only a few pins need to update at 1 MHz, but depending on how we update all the signals, 1 MHz is the maximum frequency we need in general.&lt;/p&gt;
&lt;p&gt;We are using quite some resources on the nRF52840. We have other pins used as BLE ANT, I2C, SPI. But I tried to design in such a way that all used pins are kept the maximum possible separation with the ANT pin.&lt;/p&gt;
&lt;p&gt;Please let me know if you need anything else. Hope to hear from you soon.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to generate multiple signals with timing controls (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/371165?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 13:11:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85c7ba5d-cae7-4694-9635-cd1c90f862a4</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I can see 15 signal lines here, is this some kind of parallell interface where all signal lines must be&amp;nbsp;in synchronization/timing as shown relative to eachother?&amp;nbsp;Are these bidirection lines or output only? Do I understand it correctly that you must update these pins at up to 1MHz? What can you tell me about other activities the nRF52840 must do (e.g. does it also need to execute&amp;nbsp;Bluetooth&amp;nbsp;or other timing sensitive handling)?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>