View previous topic :: View next topic |
Author |
Message |
henrry_std3
Joined: 06 Mar 2025 Posts: 3
|
WARNIGS for using USB library |
Posted: Thu Mar 06, 2025 7:31 pm |
|
|
After compiling, the monitor show this:
>>> Warning 203 "C:\Program Files (x86)\PICC\Drivers\pic18_usb.c" Line 728(1,1): Condition always TRUE
test.c" Line 17(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_token_reset)
test.c" Line 17(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_tbe)
test.c" Line 17(1,2): Interrupts disabled during call to prevent re-entrancy: (usb_cdc_flush_tx_buffer)
Code: |
#include <18F4550.h>
#fuses NOWDT, NOPROTECT, NOLVP, NOMCLR, HSPLL
#use delay(crystal = 20MHz, clock = 48MHz, USB_FULL)
#define USB_CONFIG_BUS_POWER 500
#include "usb_cdc.h"
void main(){
delay_ms(10);
usb_init();
delay_ms(10);
while(TRUE){
printf(usb_cdc_putc, "512");
delay_ms(10);
}
}
|
[/code]
Last edited by henrry_std3 on Fri Mar 07, 2025 12:59 am; edited 1 time in total |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Fri Mar 07, 2025 12:22 am |
|
|
Yes.
Not a problem.
These are warnings for guidance. The point is that the PIC does not
support re-entrancy. So a function cannot be called inside itself. To
prevent this happening, the compiler ensures that when any function
is called both inside the interrupt handler and in the external code,
it disables interrupts during the period of the call in the external routine,
and posts this warning.
It can become important if the routine involved takes a long time.
However the ones involved in this code are very short, so not a problem. |
|
 |
henrry_std3
Joined: 06 Mar 2025 Posts: 3
|
|
Posted: Fri Mar 07, 2025 12:58 am |
|
|
If I want to use interrupts like timers or external ones, can I do it? Maybe it's better to use a serial-to-USB converter instead of the USB library.
Thanks for replying. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Fri Mar 07, 2025 1:58 am |
|
|
The interrupts will all function completely normally.
Remember that on the PIC16/18 any interrupt routine will stop all other
interrupts being handled while it is being serviced. So it is completely
normal for interrupts to not be serviced for several uSeconds while another
interrupt is being handled.
Much more important is to make sure your handlers for the timers and
external events are themselves quick to handle. This is always important. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Fri Mar 07, 2025 6:11 am |
|
|
I've used those serial<>USB modules for years.They save code space( no driver_,4 wire install,preassembled so you can't swap D+ and d- and lose a day wondering WHY doesn't it work like it did 5 minutes ago ? Saves money(cost of connector, resistors, caps, get a 'status' LED.
Back then the module was about 60 cents more than buying the equal handful of parts( which of course YOU have to assemble, properly )
It also frees up the PIC to do 'other stuff' as communications is 'offloaded' to the module. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Fri Mar 07, 2025 7:24 am |
|
|
Yes. It is also worth considering that if you switch to a non USB version
of a similar chip, you will probably get 64MHz operation, save the pin
otherwise required for USB connection sense, and in many cases these
modules are actually cheaper than just buying the USB connector!....
Also if you don't require exact timing, you can then switch to using an
internal oscillator, while USB on this chip needs a crystal.
The warning is nothing, just an alert that this could in certain circumstances
cause a problem. However the pricing of some of these modules does make
them often the better solution..... |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Fri Mar 07, 2025 9:22 am |
|
|
for giggles I checked online..it's cold and WINDY here
local store here USB A connector is $3.99 and I have to drive there and back ( 1 hour total road trip.
online TTL<>USB module is $3.95 and I can stay in my nice warm house.
hmm... what should I do ???? |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Fri Mar 07, 2025 12:31 pm |
|
|
Exactly.
It amazed me too. |
|
 |
|