This issue is not documented on Microchip. There is only one document
TB3193 discussing active clock tuning for PIC16LF191XX with the 32KHz
secondary oscillator. Below is the config I've tried, it does not work, the
ACT is not locking. I can't understand how the reference clock required
for active clock tuning is derived from the USB host as long communication
does not work through the USB transceiver without clock. However some guy
reported that ACT feature works with PIC18F25K50:
https://www.microchip.com/forums/m847890.aspx. The smartest gives up....
include 18f25k50 -- target PICmicro
pragma target clock 48_000_000 -- oscillator frequency
pragma target PLLSEL PLL3X -- PLL multiplier
pragma target PLLEN ENABLED -- PLL select
pragma target CPUDIV P1 -- no divide
pragma target LS48MHz P8 -- USB 48MHz/8 = 6MHz
pragma target OSC INTOSC_NOCLKOUT -- internal OSC
pragma target PCLKEN ENABLED -- Primary Oscillator
pragma target FCMEN DISABLED -- Fail-Safe Clock Monitor
pragma target IESO DISABLED -- Oscillator Switchover mode
pragma target PWRTE ENABLED -- power up timer
pragma target BROWNOUT DISABLED -- no brownout detection
pragma target LPBOR DISABLED -- Low-Power Brown-out Reset
pragma target WDT CONTROL -- watchdog software controlled
pragma target PBADEN DIGITAL -- digital input port<0..4>
pragma target MCLR EXTERNAL -- master reset on MCLR
pragma target STVR DISABLED -- reset on stack over/under flow
pragma target LVP DISABLED -- low-voltage programming
pragma target ICPRT DISABLED -- In-Circuit Debug/Programming
Port
pragma target XINST DISABLED -- Extended Instruction Set
pragma target DEBUG DISABLED -- Background Debugger
WDTCON_SWDTEN = OFF -- disable watchdog
include delay
include print
OSCCON_IRCF = 0b111 -- select INTOSC 16MHz
OSCCON_SCS = 0b00 -- select primary clock defined by
CONFIG1H FOSC3:0
ACTCON_ACTEN = 0 -- ACT module disabled
ACTCON_ACTUD = 0 -- enable OSCTUNE update
ACTCON_ACTSRC = 1 -- set HFINTOSC to match with the USB
host clock ??
ACTCON_ACTEN = 1 -- ACT module enabled
UCFG_FSEN = 1 -- USB full speed mode
UCFG_UPUEN = 1 -- pull_up enabled
UCFG_UTRDIS = 0 -- USB transciever enabled
delay_1mS ( 2 )
UCON_USBEN = 1 -- USB enabled, this bit cannot be
enabled without apropiate clock source!
alias led_lock is pin_A0 -- alias for pin with LED ACTlock
pin_A0_direction = OUTPUT
alias led_range is pin_A1 -- alias for pin with LED OSCTUNE out
of range
pin_A1_direction = OUTPUT
alias led is pin_A2 -- alias for pin with LED blink
pin_A2_direction = OUTPUT
for 100 loop
if ACTCON_ACTLOCK == 0 then
led_lock = OFF ; not locked
delay_1mS ( 1 )
elsif ACTCON_ACTLOCK == 1 then
led_lock = ON ;16MHz ACT locked
end if
end loop
if ACTCON_ACTORS == 1 then ; out of OSCAL range
led_range = on
elsif ACTCON_ACTORS == 0 then ; in the OSCAL range
led_range = off
end if
enable_digital_io() -- make all pins digital I/O
INTCON_GIE = false
const byte str_welcome[] = "USB Serial HFINTOSC Demo app\n"
include usb_serial
usb_serial_init()
var bit has_shown_welcome_msg = true
var byte ch = "A"
forever loop
if ( usb_cdc_line_status() != 0x00 ) then
if !has_shown_welcome_msg then
has_shown_welcome_msg = true
print_string( usb_serial_data, str_welcome )
end if
else
has_shown_welcome_msg = false
end if
usb_serial_flush()
usb_serial_data = ch
; _usec_delay(100_000)
led = ON
_usec_delay(100_000)
led = OFF
_usec_delay(400_000)
end loop
On Fri, Feb 19, 2021 at 11:40 AM vsurducan <[email protected]> wrote:
> Hi Oliver,
> yes the ACT seems to be activated, but I'm not sure it is properly set.
> ACTCON = 0b1001_1000 (90h) -- ACT module enabled,
> INTOSC locked at 0.02% on USB host clock, updates to OSCTUNE
> I saw also other weird issues:
> -on full speed USB (FSEN = 1, UPUEN=1 ) the pull-up should be set on +D,
> -on low speed USB pull-up (FSEN = 0, UPUEN = 1) the pull-up should be on
> -D, however only pull-up on +D can be observed by measurement.
> thx,
> Vasile
>
>
> On Fri, Feb 19, 2021 at 11:22 AM 'Oliver Seitz' via jallib <
> [email protected]> wrote:
>
>> Hi!
>>
>> Allowable clock tolerance for full speed USB is +/- 0.25%. Without
>> the Active Clock Tuning (ACT) Module, the internal oscillator doesn't meet
>> that accuracy. Did you activate that modue?
>>
>> Greets,
>> Kiste
>>
>>
>>
>>
>> Am Freitag, 19. Februar 2021, 07:45:43 MEZ hat vsurducan <
>> [email protected]> Folgendes geschrieben:
>>
>>
>>
>>
>>
>> Thx Rob. You point out the problem well. I'm testing with PIC18F25k50.
>> With 16MHz HS and 3x PLL the USB communication works ok.
>> However with 16MHz INTOSC and PLL, I continuously get the same error "USB
>> device has a malfunction..." WIN does not read the USB descriptor, perhaps
>> because of wrong or unstable frequency on the USB module.
>> On the other hand, PIC18F25K50 USB oscillator description is quite weird:
>> For low speed, USB module must have a 6MHz clock by setting the LS48MHz
>> bit (table 3.6 page 47 DS30000684B datasheet). This is crystal clear.
>> For high speed, USB module must have 48MHz, but no description of how to
>> do that is given (table 3.7, the same page).
>> Fig.1 at page 29 shows the clock structure for USB. What has to be set
>> to have a 48MHz USB clock?
>> I will dig more...
>>
>>
>> On Thu, Feb 18, 2021 at 8:22 PM Rob CJ <[email protected]> wrote:
>> >
>> >
>> > Hi Vsurducan,
>> >
>> >
>> >
>> >
>> > The datasheet of the 18f14k50 states this:
>> >
>> >
>> >
>> >
>> > "For full-speed USB operation, a 48 MHz clock is required for the USB
>> Module. To generate the 48 MHz clock, only two oscillator modes are allowed:
>> >
>> > -) EC High-Power mode
>> >
>> > -) HS Mode"
>> >
>> >
>> >
>> >
>> > I have seen a sample file that runs at 48 MHz but uses the internal
>> oscillator, see 18f67j50_usb_serial.jal.
>> >
>> >
>> >
>> >
>> > I am not sure if this answers your question.
>> >
>> >
>> >
>> >
>> > Kind regards,
>> >
>> >
>> >
>> >
>> > Rob
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > ________________________________
>> > Van: [email protected] <[email protected]> namens
>> vsurducan <[email protected]>
>> > Verzonden: donderdag 18 februari 2021 15:09
>> > Aan: [email protected] <[email protected]>
>> > Onderwerp: [jallib] USB issue
>> >
>> >
>> >
>> >
>> >
>> > Hi, I've seen two complete examples of using USB libraries; both are
>> bootloaders, one using 18F4450 and the other 18F14k50.
>> >
>> > Both are using USB clocks at 48MHz, so USB runs in full speed mode.
>> Both use an external crystal in HF mode and PLL to acquire 48MHz clock.
>> >
>> > The bootloader for 18F4450 works ok also on 18F2550 without any
>> issue...I've tested a while ago.
>> >
>> >
>> >
>> > I'm trying to use usb_serial on a 18F25k50 running in INTOSC mode 48MHz
>> (16Mhz and 3x PLL) and USB module in low speed mode (6MHz). The computer
>> does not read OK the USB device descriptor when the PIC is connected. This
>> can be a communication issue but also a software error.
>> >
>> >
>> >
>> > Anyone know if full speed is mandatory for these USB libraries?
>> >
>> > Maybe there is another example of using USB which I missed?
>> >
>> >
>> >
>> > thank you all,
>> >
>> >
>> >
>> >
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "jallib" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [email protected].
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jallib/CAM%2Bj4qsKAjTVPRWpNFcj4FpXQLWR2fG72JvHwj%3D4r8snkUdTwA%40mail.gmail.com
>> .
>> >
>> >
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "jallib" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [email protected].
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jallib/AM0PR07MB62412A9D03749696FCE18131E6859%40AM0PR07MB6241.eurprd07.prod.outlook.com
>> .
>> >
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "jallib" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jallib/CAM%2Bj4qsprDUG6EeUGvFKy4UZ1WozYrAzbSmg%2BcAob5DFFENz_w%40mail.gmail.com
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "jallib" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jallib/1593689859.146178.1613726536055%40mail.yahoo.com
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jallib/CAM%2Bj4qs0DK%2Bo7ihNxBxG3Uy_-riet_C%3Di6%2BZikH9%2BbGBPjOEXw%40mail.gmail.com.