Hi,

1. system clock frequency:16MHz
2. which PWM: PWM2
3. frequency on PWM timer: 32758

Jack

Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl> 於 2021年3月15日 週一 下午3:33寫道:

> Hi,
>
> I don't remember details to answer number 3 out of my head. But we
> will find out soon.
> In the meanwhile can you give me:
> 1. system clock frequency that you have selected
> 2. which PWM is causing problem.
> 3. what is frequency on PWM timer.
> Those will help me setup environment closer to what you have.
>
> br
> Jerzy
>
> niedz., 14 mar 2021 o 02:28 范姜徐霖 <jackfa...@gmail.com> napisał(a):
> >
> > Hi,
> >
> > 1. Do you know if tick is negative at line that you marked
> > if (ticks < _REG32(tmr->pwm_regs, PWM_CMP0)) { <====question code
> >
> > In my program : PWM_CMP0=0xffff, PWM_CMP1=0xffff, PEM_CFG=0xc0001209,
> ticks
> > =0x6a
> > my observation: 0x6a written in PWM_CMP1, this trigger pwm interrupt
> > (fe310_pwm_cmp1_handler)
> >  and the handler call fe310_tmr_check_first again, then trigger  pwm
> > interrupt, and so on..
> >
> > 2. I am sorry I can not share project with you, it is company project.
> >     I can provide program running info
> >
> > 3. I have a question about hal_timer_cnt function .
> > how does the code check overflow condition?
> >
> > Thanks for your help.
> >
> > --------------------------------------------------
> > static uint32_t
> > hal_timer_cnt(struct fe310_hal_tmr *tmr)
> > {
> >     uint32_t cnt;
> >     int sr;
> >     uint32_t regs = (uint32_t) tmr->pwm_regs;
> >
> >     __HAL_DISABLE_INTERRUPTS(sr);
> >     cnt = _REG32(regs, PWM_S) + tmr->value;
> >     /* Check if just overflowed */
> >     if (_REG32(regs, PWM_CFG) & PWM_CMP0) {  <====question code
> >         cnt += _REG32(regs, PWM_CMP0) + 1;
> >     }
> >     __HAL_ENABLE_INTERRUPTS(sr);
> >
> >     return cnt;
> > }
> > -----------------------------------------------------
> >
> > Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl> 於 2021年3月13日 週六 下午11:35寫道:
> >
> > > Hi,
> > >
> > > 1. Do you know if tick is negative at line that you marked
> > > if (ticks < _REG32(tmr->pwm_regs, PWM_CMP0)) { <====question code
> > >
> > > 2. Can you share your project with me somehow so I could take a look
> > > (presuming it is running on hifive1 board)?
> > >
> > > I can take a look at this next Monday.
> > >
> > > best regards
> > > Jerzy
> > >
> > > sob., 13 mar 2021 o 12:24 范姜徐霖 <jackfa...@gmail.com> napisał(a):
> > > >
> > > > I want to run ble_app sample code using SIFIVE mcu.
> > > > I modify the bsp from nordic to my board and change mcu to sifive.
> > > > I copy apache-mynewt-nimble/nimble/drivers/native and
> > > > modify it to simulate radio hardware. for now it just for not stuck
> code
> > > > running.
> > > >
> > > > I load code and run , I got some ble log messages below.
> > > >
> > > > after checking code, I found
> > > > inside hal_timer_start_at() function, it call fe310_tmr_check_first
> and
> > > > it seems not operate correctly.
> > > > It will issue pwm interrupt continuely, so it stuck.
> > > >
> > > > is there anyone help ? or I missing something?
> > > >
> > > >
> -----------------------------------------------------------------------
> > > > static void
> > > > fe310_tmr_check_first(struct fe310_hal_tmr *tmr)
> > > > {
> > > >     struct hal_timer *ht;
> > > >
> > > >     ht = TAILQ_FIRST(&tmr->sht_timers);
> > > >     if (ht) {
> > > >         uint32_t cnt = hal_timer_cnt(tmr);
> > > >         int32_t ticks = (int32_t)(ht->expiry - cnt);
> > > >         if (ticks < _REG32(tmr->pwm_regs, PWM_CMP0)) { <====question
> code
> > > >             _REG32(tmr->pwm_regs, PWM_CMP1) = ticks;   <====question
> code
> > > >             plic_enable_interrupt(tmr->pwmxcmp0_int + 1);
> > > <====question
> > > > code
> > > >             return;
> > > >         }
> > > >     }
> > > >     _REG32(tmr->pwm_regs, PWM_CMP1) = _REG32(tmr->pwm_regs,
> PWM_CMP0);
> > > >      /* Disable PWMxCMP1 interrupt, leaving only CMP0 which is used
> all
> > > the
> > > > time */
> > > >     plic_disable_interrupt(tmr->pwmxcmp0_int + 1);
> > > > }
> > > >
> > >
> ------------------------------------------------------------------------------
> > > >
> > > >
> > > > =================================================
> > > > 000000 [ts=0us, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x0
> > > ocf=0x0
> > > > 000001 [ts=7812us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x03
> > > ocf=0x0003
> > > > len=0
> > > > 000002 [ts=15624us, mod=4 level=0] 0x03 0x0c 0x00
> > > > 000002 [ts=15624us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x3
> > > > ocf=0x3 status=0
> > > > 000003 [ts=23436us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x04
> > > ocf=0x0001
> > > > len=0
> > > > 000004 [ts=31248us, mod=4 level=0] 0x01 0x10 0x00
> > > > 000005 [ts=39060us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x4
> > > > ocf=0x1 status=0 hci_ver=9 hci_rev=0 lmp_ver=9 mfrg=65535
> lmp_subver=0
> > > > 000006 [ts=46872us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x03
> > > ocf=0x0001
> > > > len=8
> > > > 000007 [ts=54684us, mod=4 level=0] 0x01 0x0c 0x08 0x90 0x80 0x00 0x02
> > > 0x00
> > > > 0x80 0x00 0x20
> > > > 000008 [ts=62496us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x3
> > > > ocf=0x1 status=0
> > > > 000009 [ts=70308us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x03
> > > ocf=0x0063
> > > > len=8
> > > > 000010 [ts=78120us, mod=4 level=0] 0x63 0x0c 0x08 0x00 0x00 0x80 0x00
> > > 0x00
> > > > 0x00 0x00 0x00
> > > > 000011 [ts=85932us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x3
> > > > ocf=0x63 status=0
> > > > 000012 [ts=93744us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > ocf=0x0001
> > > > len=8
> > > > 000013 [ts=101556us, mod=4 level=0] 0x01 0x20 0x08 0x7f 0xfe 0x0f
> 0x00
> > > 0x00
> > > > 0x00 0x00 0x00
> > > > 000014 [ts=109368us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x1 status=0
> > > > 000015 [ts=117180us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0002 len=0
> > > > 000016 [ts=124992us, mod=4 level=0] 0x02 0x20 0x00
> > > > 000016 [ts=124992us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x2 status=0
> > > > 000017 [ts=132804us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0003 len=0
> > > > 000018 [ts=140616us, mod=4 level=0] 0x03 0x20 0x00
> > > > 000019 [ts=148428us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x3 status=0
> > > > 000020 [ts=156240us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x04
> > > > ocf=0x0009 len=0
> > > > 000020 [ts=156240us, mod=4 level=0] 0x09 0x10 0x00
> > > > 000021 [ts=164052us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x4
> > > > ocf=0x9 status=0 bd_addr=0:0:0:0:0:0
> > > > 000022 [ts=171864us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x002d len=1
> > > > 000023 [ts=179676us, mod=4 level=0] 0x2d 0x20 0x01 0x00
> > > > 000024 [ts=187488us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x2d status=0
> > > > 000025 [ts=195300us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0029 len=0
> > > > 000026 [ts=203112us, mod=4 level=0] 0x29 0x20 0x00
> > > > 000026 [ts=203112us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x29 status=0
> > > > 000027 [ts=210924us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x002d len=1
> > > > 000028 [ts=218736us, mod=4 level=0] 0x2d 0x20 0x01 0x01
> > > > 000029 [ts=226548us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x2d status=0
> > > > 000030 [ts=234360us, mod=4 level=1] GAP procedure initiated: stop
> > > > advertising.
> > > > 000030 [ts=234360us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x000a len=1
> > > > 000031 [ts=242172us, mod=4 level=0] 0x0a 0x20 0x01 0x00
> > > > 000032 [ts=249984us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0xa status=0
> > > > 000033 [ts=257796us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0027 len=39
> > > > 000034 [ts=265608us, mod=4 level=0] 0x27 0x20 0x27 0x00 0x00 0x00
> 0x00
> > > 0x00
> > > > 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > > 0x00
> > > > 0x00 0x00 0x00 0xef 0x8d 0xe2 0x16 0x4f 0xec 0x43 0x0d 0xbf 0x5b 0xdd
> > > 0x34
> > > > 0xc0 0x53 0x1e 0xb8
> > > > 000037 [ts=289044us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x27 status=7
> > > > 000037 [ts=289044us, mod=4 level=0] looking up peer sec;
> > > > 000038 [ts=296856us, mod=4 level=1] ble_hs_cfg
> > > > 000038 -ble_app_on_sync-
> > > > 000039 [ts=304668us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0018 len=0
> > > > 000040 [ts=312480us, mod=4 level=0] 0x18 0x20 0x00
> > > > 000040 [ts=312480us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x18 status=0 rand=0x0001020304050607
> > > > 000042 [ts=328104us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0005 len=6
> > > > 000042 [ts=328104us, mod=4 level=0] 0x05 0x20 0x06 0x00 0x01 0x02
> 0x03
> > > 0x04
> > > > 0x05
> > > > 000043 [ts=335916us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x5 status=0
> > > > 000044 addr:0x900019dd
> > > > 000045 [ts=351540us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0008 len=32
> > > > 000045 [ts=351540us, mod=4 level=0] 0x08 0x20 0x20 0x1e 0x02 0x01
> 0x06
> > > 0x1a
> > > > 0xff 0x4c 0x00 0x02 0x15 0x11 0x11 0x11 0x11 0x11 0x11 0x11 0x11 0x11
> > > 0x11
> > > > 0x11 0x11 0x11 0x11 0x11 0x11 0x00 0x02 0x00 0x0a 0x00 0x00
> > > > 000048 [ts=374976us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x8 status=0
> > > > 000049 [ts=382788us, mod=4 level=1] GAP procedure initiated:
> advertise;
> > > > disc_mode=0 adv_channel_map=0 own_addr_type=1 adv_filter_policy=0
> > > > adv_itvl_min=0 adv_itvl_max=0
> > > > 000051 [ts=398412us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x0006 len=15
> > > > 00001 [ts=398412us, mod=4 level=0] 0x06 0x20 0x0f 0xa0 0x00 0xf0 0x00
> > > 0x03
> > > > 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00
> > > > 000053 [ts=414036us, mod=4 level=0] Command complete: cmd_pkts=1
> ogf=0x8
> > > > ocf=0x6 status=0
> > > > 000054 [ts=421848us, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08
> > > > ocf=0x000a len=1
> > > > 000055 [ts=429660us, mod=4 level=0] 0x0a 0x20 0x01 0x01
> > > > =================================================
> > > >
> > > > it stuck here, no more any message..
> > >
>

Reply via email to