Pic 18F87J94 clock timing problem

General discussion on mikroBasic PRO for PIC.
Author
Message
dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Pic 18F87J94 clock timing problem

#1 Post by dmtulsa » 28 Aug 2014 23:27

Hello, I've been using your basic compiler pro and have several development boards for a few years now and I love it. I'd post it on the forum, it is critical to my project to resolve this. It may be all my fault also.
I'm using the Microchip PicDem 18 board and a 18F87J94 PIM (plug in module ) since the easyPic 7 pro board does not support this chip yet. The compiler is MikroEmBasic pro 6.4. I have replaced the primary OSC on the PicDem board with a 20mhz crystal and I do have 20mhz at the 18f87j94 osc1 pin.
My problem is with the 18f87j94 configured for a 20mhz primary osc it should be running at 64mhz internal clock with 96mhz pll as I have it configured. As you can see with the attached code when running a loop of bcf, bsf at 4 cycles per instruction and 64mhz /8 = 8mhz at portd.0 and that is what I see on a o-scope. This is correct.
When I run a setbit, clearbit loop the timing is way off. To see this please run and check with a o-scope with the ASM code. Then comment out the ASM code and uncomment the setbit - clearbit code and you should see that the timing is way off.
I thank you very much for looking at this. It is a very important project for me and my client is beating me up to get this to work.
I am going to try to set the chip up to use the internal clock and pll and see if that makes a difference.
It may be all my fault but can you please take a look.

I am using MPLAB 8.92 and a IDC3 to program the chip. I import the .HEX created by MikroE basic pro then program.

Thank you
Doug McDonald
dougm@unicorpok.com
dmtulsa@cox.net

Please see attached file, zipped source code
Attachments
SIG Caliper Tool j94.zip
(62.46 KiB) Downloaded 148 times
Doug
KD5NWK

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#2 Post by dmtulsa » 30 Aug 2014 20:29

My Agilent scope will not do screen shots. But after the weekend when I get back to work I' show that using ASM the clocks are correct but when using mBasic code the timing is off by around 20% with my Tek-mso scope. Using an external osc or the internal FRCPLL the asm code is correct and the mBasic code is not. I have attached the code in a prior post. Please some one at mikroE take a look at this. Code in MPLAB works fine so I can only guess there is something wrong with a setting in Mbasic for this chip. I may be wrong, if so I'm sorry.

Thank you
Doug
KD5NWK

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#3 Post by dmtulsa » 04 Sep 2014 16:19

Please see attached document that shows 0-scope screen shots of the timing problems. Also attached is the projects for both 20mhz and FRC clocks
Docs.zip
(148.54 KiB) Downloaded 141 times
18F87J94_FRC.ZIP
(62.02 KiB) Downloaded 131 times
18F87J94_20mhz.zip
(62.39 KiB) Downloaded 139 times
Doug
KD5NWK

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Pic 18F87J94 clock timing problem

#4 Post by filip » 05 Sep 2014 15:18

Hi,

I have tested today this very chip on 64 MHz and it works OK.
The project attached is for mikroC, but it will give you enough information.

Try this and inform me of the results.

Regards,
Filip.
Attachments
Led Blinking.rar
(1.84 KiB) Downloaded 155 times

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#5 Post by dmtulsa » 08 Sep 2014 15:52

Filp, I tried the program you posted. I used my ICD3 and MPLAB to download the .hex file. It doesn't do anything. It should toggle ports A-E every second but nothing happens. I reloaded the programs I posted and they work but for the timing issue.
I do not have the C compiler so there's not much I can do to see whats wrong. I did notice that your .cgf is very different than the one's I posted with my project.
I have down loaded some .hex files from microchip and everything seems to work fine.
Again I'm using the PICdem 18 board with the 18f87j94 PIM for it. This should not make any difference.

Any more ideas
Doug
KD5NWK

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#6 Post by dmtulsa » 08 Sep 2014 16:46

Flip, I think I see the problem. The project you sent is set up for 8 mhz primary osc. As I said in an earlier post I'm using a 20mhz osc. on the PicDem-18 board. I can also use FRC for testing purposes.
Can you please change the config and re-build the project and send it to me again.

Thank you
Doug
Doug
KD5NWK

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Pic 18F87J94 clock timing problem

#7 Post by filip » 09 Sep 2014 10:17

Hi,

Please find the project in the attachment.

Regards,
Filip.
Attachments
LedBlinking.rar
(1.79 KiB) Downloaded 157 times

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#8 Post by dmtulsa » 09 Sep 2014 14:43

Flip, with the change to the config the C program works correctly. I can only assume that there is an error in the basic compiler or support files having to do with the 18Fx7J94 chips.

Thank you
Doug
Doug
KD5NWK

strud
Posts: 77
Joined: 12 Jun 2009 04:24

Re: Pic 18F87J94 clock timing problem

#9 Post by strud » 10 Sep 2014 07:31

Iam following this with some interest since we are also using this chip with the same external oscillator.

I assume it is probably an oversight but in the last project attached, the Primary oscillator select config has been set to MS ie 3.5 to 10MHz, which I assume should be set to HS.

CS

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#10 Post by dmtulsa » 10 Sep 2014 13:57

Which project exactly where you talking about? Of the two I posted the 20mhz was set to HS w/PLL and the other was set to FRC MS with PLL. The last Flip sent your correct it was set at config2H 20mhz /5 pll but in config3L it was set as MS. I didn't catch that but it worked okay as far as the timing went.

I think it is pretty clear there is an issue with basic pro 6.4.0 This chip family was just added with this version.

Thanks
Doug
Doug
KD5NWK

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Pic 18F87J94 clock timing problem

#11 Post by filip » 10 Sep 2014 15:26

Hi,
I think it is pretty clear there is an issue with basic pro 6.4.0 This chip family was just added with this version.
I think there is no issue with this version regarding the reported problem.
The only thing that was an issue here is the incorrect setting of the configuration bits in the Edit Project.

I have attached an example program to demonstrate this.
I assume it is probably an oversight but in the last project attached, the Primary oscillator select config has been set to MS ie 3.5 to 10MHz, which I assume should be set to HS.
Yes, this is an oversight, but it worked out anyway. :)

Regards,
Filip.

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#12 Post by dmtulsa » 10 Sep 2014 15:50

Flip, Did you forget to attach the project. I hope your correct that it is only a config issue. I assume that your going to attach has the proper config showing me my error

Thank you
Doug
KD5NWK

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#13 Post by dmtulsa » 11 Sep 2014 15:35

I think there is no issue with this version regarding the reported problem.
The only thing that was an issue here is the incorrect setting of the configuration bits in the Edit Project.
I think there is some confusion. The config HS / MS error was in your C example not in my project. I still have the same issue. If it was in my project can you please tell me what the error is. As per the data sheet everything is correct unless I made a stupid mistake.

Your last post suggested your posting another "working" project I assume in basic. I have not seen that posted yet.

Thank you
Doug
KD5NWK

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Pic 18F87J94 clock timing problem

#14 Post by filip » 12 Sep 2014 13:38

Hi,

I forgot to attach the project, please find it attached now.
It is set for 20 MHz input clock source and 64 MHz MCU clock.

Regards,
Filip
Attachments
LedBlinking.rar
(1.37 KiB) Downloaded 126 times

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: Pic 18F87J94 clock timing problem

#15 Post by dmtulsa » 15 Sep 2014 14:42

Flip, Sorry to say this but the file you uploaded would not run. You had the clock source set to 64mhz when it should have been set to 20mhz. When I set it to 20 it ran but the timing is still off by the same amount. Each 1 second pulse in code shows 400ms on the scope. I really need to get this fixed or I'm going to loose this contract work.

Thank you
Doug
KD5NWK

Post Reply

Return to “mikroBasic PRO for PIC General”