|
|
View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
Posted: Tue Nov 05, 2019 9:16 am |
|
|
Yes, even stack=0x400 and didn't work. _________________ Electric Blue |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Thu Nov 07, 2019 2:11 am |
|
|
You are calling usb_init?.
Try a really basic code like the CCS serial example.
Go and 'triple check' the connections. In particular the polarity of D+ & D-
the only time I couldn't get a board to initialise I had fitted a 'R' connector
that had the pin order reversed (designed to mount on the back of the
board).
Is D+ being taken high when the device is plugged in?.
The header was taken from a working data logger. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9097 Location: Greensville,Ontario
|
|
Posted: Thu Nov 07, 2019 5:31 am |
|
|
re: In particular the polarity of D+ & D-
the only time I couldn't get a board to initialise I had fitted a 'R' connector
that had the pin order reversed (designed to mount on the back of the
board).
WOW, and I thought I was the ONLY one who had THAT happen to !! One of those 'worked in the morning,not in the afternoon when I 'cleaned up the rats nest' to stuff into a box'.
After that I bought USB-TTL modules, money well spent...no more USB 'issues'.
Jay |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
Posted: Thu Nov 07, 2019 8:41 am |
|
|
The hardware seems to be ok because I just made a simple program with MPLAB Code Configurator (MCC) and runs ok; I got COM16.
The problem now is that my code is for CCS not XC16.
Before this I tried to get the USB Eye pattern with no luck.
Code: | #include <24FJ1024GB606.h>
#build(STACK=0x400)
#use delay(internal=32000000,USB_FULL, ACT=USB)
#bit UTEYE = getenv("BIT:UTEYE")
#bit USBEN = getenv("BIT:USBEN")
#bit USB1MD = getenv("BIT:USB1MD")
#bit DMPULUP = getenv("BIT:DMPULUP")
#bit DPPULUP = getenv("BIT:DPPULUP")
#bit USBPWR = getenv("BIT:USBPWR")
void main()
{
set_tris_g(0b11001001100);
set_tris_f(0b10001000);
UTEYE=1;
USBEN=1;
USB1MD=1;
DMPULUP=1;
DPPULUP=1;
USBPWR=1;
while(1)
{
output_toggle(PIN_D7);
delay_ms(2);
}
}
|
But when I halt the program the bits didn't get set. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Thu Nov 07, 2019 9:10 am |
|
|
Pulling up both lines is never legitimate in USB. A full speed device pulls up
D+, a low speed device D-.
The settings for EYE, are USBPWR=1, UTEYE=1, and SUSPEND=0.
USUSPND=0
Be aware the device should not be connected to a USB bus when this is set. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
Posted: Thu Nov 07, 2019 9:38 am |
|
|
I think CCS is setting up the fuses wrong
Check this is what CCS set up
This is XC16
Check FOSCSEL and FOSC 96MHz PLL is disabled and should be enabled and says PLL is fed by primary oscillator, that's completely wrong.
Also there's no option in 24FJ1024GB606.h file to set the 96MHz PLL on.
There's any way to set up config fuses by an hexadecimal?
Maybe something like
#fuses FOSCSEL 0xFFFF89
#fuses FOSC 0XFFFA7
Or with #pragma, I never used #pragma before. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Thu Nov 07, 2019 10:36 am |
|
|
Get rid of your USB_FULL setting. You will notice I don't use this. This is
specifically to configure the primary oscillator to support USB. By default
the code automatically sets to timings correctly, and this may be what is
actually stopping it working....
If you look in the example, the setting using ACT, does not use this setting. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
Posted: Fri Nov 08, 2019 6:27 am |
|
|
I already did it, same results.
I'm going to try to port the code to XC16
I can't believe that there's no way to set the fuses manually. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Fri Nov 08, 2019 7:50 am |
|
|
Of course you can set the fuses manually.
Just set them.
Key thing though is to do it after the #use delay statement. This overrides
the fuses controlling the clock.
However I doubt if this is actually the problem. CCS by default always
wakes chips up with the PLL disabled, and then enables it at the start of
the code. This is done, because many PIC's do not support starting with the
PLL enabled, and even more have errata that apply when this is done.
Simpler and safer to always set the fuses to not enable it.
Going to try the experiment of compiling some test code for your chip
and compare with the same code compiled for the smaller chip. Most likely
thing is an error somewhere in the device database for your specific chip. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Fri Nov 08, 2019 8:01 am |
|
|
Just checked, and compiled this:
Code: |
#include <24FJ1024GB606.h>
#fuses NOWDT //Needed
#use delay(internal=32MHz, USB_FULL,ACT)
#define __USB_PIC_PERIF__ 1
#bit U1OTGSTAT_SESVD=getenv("BIT:SESVD")
#define USB_CABLE_IS_ATTACHED() (U1OTGSTAT_SESVD) //cable attached for DsPIC
#include <usb_cdc.h>
#include <pic24_usb.h>
void main(void)
{
usb_cdc_init();
while (TRUE)
{
if (usb_cdc_kbhit())
usb_cdc_putc(usb_cdc_getc());
usb_task();
}
}
|
One glaring problem. The watchdog is enabled.
Added #fuses NOWDT, and compiled again, and PLL2 is enabled.
Both with the current compiler and your version.
Have you been disabling the watchdog?. It won't work unless you do
the chip will be continuously resetting every couple of mSec. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
Posted: Fri Nov 08, 2019 8:04 am |
|
|
How I can set fuses manually if there no option; some PIC18 have a 96MHz PLL and the setup for the divider not the 24F1024GB606.
Code: | //////// Program memory: 352128x24 Data RAM: 32768 Stack: 31
//////// I/O: 52 Analog Pins: 16
//////// Fuses: WRTB,BSSHS,BSSSS,NOBSS,BS,WRT,PROTECT_HIGH,PROTECT,NOPROTECT
//////// Fuses: WPCFG,PROTECT_HIGH_CFG,PROTECT_ENH_CFG,PROTECT_CFG
//////// Fuses: NOPROTECT_CFG,AIVT,BSS,FRC,FRC_PLL,PR,PR_PLL,SOSC,LPRC,DCO
//////// Fuses: FRC_PS,PLL4X,PLL6X,PLL8X,NOPLL,IESO,EC,XT,HS,NOPR,OSCIO
//////// Fuses: SOSC_DIG,SOSC_SEL,PLL_FROM_FRC,PLL_FROM_PRIMARY,IOL1WAY
//////// Fuses: CKSFSM,CKSNOFSM,NOCKSNOFSM,WPOSTS1,WPOSTS2,WPOSTS3,WPOSTS4
//////// Fuses: WPOSTS5,WPOSTS6,WPOSTS7,WPOSTS8,WPOSTS9,WPOSTS10,WPOSTS11
//////// Fuses: WPOSTS12,WPOSTS13,WPOSTS14,WPOSTS15,WPOSTS16,WDT32,WDT128
//////// Fuses: NOWDT,WDT_NOSL,WDT_SW,WDT,WINDIS,WDTWIN_75%,WDTWIN_50%
//////// Fuses: WDTWIN_37%,WDTWIN_25%,WDTCMX,WDTCLK_SYS,WDTCLK_SOSC
//////// Fuses: WDTCLK_31KHZ,WDTCLK_LPRC,NOBROWNOUT,BROWNOUT_SW
//////// Fuses: BROWNOUT_NOSL,BROWNOUT,LVR,DNVP,ICSP3,ICSP2,ICSP1,JTAG,DEBUG
//////// Fuses: BTSWP,ALTCMPI,TMPRPIN,SOSC_LOW,SOSC_HIGH,VREFALT_CVREFALT
//////// Fuses: VREFNORM_CVREFNORM
//////// |
_________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Fri Nov 08, 2019 8:09 am |
|
|
Read the manual.
You can set any fuse word by number.
#fuses 2 = 0xCC55AA
sets fuse word 2 to 0xCC55AA
Just looked at the listing, and the value you are showing your compiler
as generating FFFFFF9, is not what the compiler generates for the fuses
given.
The PLLn settings control the divider.
Every fuse the chip has can be set using the CCS values. However your
compiler is old enough to lack some:
Code: |
//////// Fuses: WRTB,NOWRTB,BSSHS,BSSSS,NOBSS,BS,NOBS,WRT,NOWRT,PROTECT_HIGH
//////// Fuses: PROTECT,NOPROTECT,WPCFG,NOWPCFG,PROTECT_HIGH_CFG
//////// Fuses: PROTECT_ENH_CFG,PROTECT_CFG,NOPROTECT_CFG,AIVT,NOAIVT,BSS
//////// Fuses: FRC,FRC_PLL,PR,PR_PLL,SOSC,LPRC,DCO,FRC_PS,PLL1,PLL2,PLL3
//////// Fuses: PLL4,PLL5,PLL6,PLL5,PLL12,PLL4X,PLL6X,PLL8X,NOPLL,NOIESO
//////// Fuses: IESO,EC,XT,HS,NOPR,OSCIO,NOOSCIO,SOSC_DIG,SOSC_SEL
//////// Fuses: PLL_FROM_FRC,PLL_FROM_PRIMARY,NOIOL1WAY,IOL1WAY,CKSFSM
//////// Fuses: CKSNOFSM,NOCKSNOFSM,WPOSTS1,WPOSTS2,WPOSTS3,WPOSTS4,WPOSTS5
//////// Fuses: WPOSTS6,WPOSTS7,WPOSTS8,WPOSTS9,WPOSTS10,WPOSTS11,WPOSTS12
//////// Fuses: WPOSTS13,WPOSTS14,WPOSTS15,WPOSTS16,WDT32,WDT128,NOWDT
//////// Fuses: WDT_NOSL,WDT_SW,WDT,NOWINDIS,WINDIS,WDTWIN_75%,WDTWIN_50%
//////// Fuses: WDTWIN_37%,WDTWIN_25%,NOWDTCMX,WDTCMX,WDTCLK_SYS,WDTCLK_SOSC
//////// Fuses: WDTCLK_31KHZ,WDTCLK_LPRC,NOBROWNOUT,BROWNOUT_SW
//////// Fuses: BROWNOUT_NOSL,BROWNOUT,LVR,NOLVR,NODNVP,DNVP,ICSP3,ICSP2
//////// Fuses: ICSP1,NOJTAG,JTAG,DEBUG,NODEBUG,BTSWP,NOBTSWP,ALTCMPI
//////// Fuses: NOALTCMPI,TMPRPIN,NOTMPRPIN,SOSC_LOW,SOSC_HIGH
//////// Fuses: VREFALT_CVREFALT,VREFNORM_CVREFNORM
|
These were fixed at about 5.080.[/code]
Last edited by Ttelmah on Fri Nov 08, 2019 8:26 am; edited 1 time in total |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 406
|
|
Posted: Fri Nov 08, 2019 8:26 am |
|
|
Already did it, only works with fuses 1
Also must be no space next to the '='
Compiles ok
Error at compile time
Code: | #fuses 2 = 0xCC55AA; |
Anyways, it doesn't change any fuse beyond the first one
Your last program do nothing.
If I use
Code: | #define USB_CON_SENSE_PIN PIN_F7 |
At least I get the unknown device balloon. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Fri Nov 08, 2019 8:34 am |
|
|
Seriously, merrily works for me, using your compiler version:
Code: |
#include <24FJ1024GB606.h>
#fuses NOWDT
#use delay(internal=32MHz, ACT)
|
Generates:
Code: |
Word 7L: FF89 FRC_PLL PLL2 IESO
H: 0000
|
Then instead compile with:
Code: |
#include <24FJ1024GB606.h>
#fuses NOWDT
#use delay(internal=32MHz, ACT)
#fuses 7=0x0000 //test to see if fuses change
|
and merrily generates:
Code: |
Word 7L: 0000 FRC PLL1 NOIESO
H: 0000
|
As you can see it has left it's own 'fuse comments', but has changed the
word to 0000. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|