PIC18F4620 Compiles but does not Run

General discussion on mikroPascal PRO for PIC.
Author
Message
amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

PIC18F4620 Compiles but does not Run

#1 Post by amfortas » 09 Oct 2014 16:50

My habitual PICs are 18F452 and 18F4620 . I convert to 4620 when I need more memory.
Now I find that PIC18F4620 devices compile but do not run or run and hang. I use EasyPic6 for prototype development so that is the hardware.

My atrocious environment is Win 8.1 having been bullied of XP.

I am tempted to reload PascalPro - however I would be interested to hear of reasons why the 18F4620 should become a problem when the 18F452 compiles and runs as expected(Identical code).

I may have done something less than clever but MPP does very occasionally crash under Win8.1 which I never ever experienced under XP. I cannot put my finger on it.

Very many thanks,

Amfortas

MaGiK
Posts: 897
Joined: 19 Apr 2013 10:00

Re: PIC18F4620 Compiles but does not Run

#2 Post by MaGiK » 10 Oct 2014 17:58

Hello Amfortas :D

Could you please provide more info on this?
Such as, which version of compiler are you using?
Which version of MikroProg suite are you using?
Can you post your code here?

Best Regards :D
My hobby is collecting MikroElektronika products.
Gotta catch them all!

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#3 Post by amfortas » 10 Oct 2014 18:30

Hi MaGik,

My MikroProg Suite is 2,27 has worked fine on PIC18F4620. I am simply running the Library LED program which has previously worked fine. (I have also tried a very simple LED flashing prog.).

I a using the EasyPIC6 built in MikroFlash - the program loads and verifies as expected. Also use MikroProg on product hardware which first showed the problem. The program does nothing so I assume it hangs before running.

Appears to behave perfectly on all PIC18F452 progs.

I would have to deduce that there is something wrong with the PIC18F4620 header file but simply wondered whether anyone else had a similar experience. Probably coincides with my downgrading to WIN8.1 !

Thanks for responding,

Regards,

Amfortas

MaGiK
Posts: 897
Joined: 19 Apr 2013 10:00

Re: PIC18F4620 Compiles but does not Run

#4 Post by MaGiK » 10 Oct 2014 18:56

Hello amfortas :D

Latest version of (MikroProg suite) software is V2.30.
Could you please install it from the following link and try again?
http://www.mikroe.com/mikroprog/pic-dspic-pic32/

Please let me know if that didn't solve your issue :D
Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!

MicroMark
Posts: 181
Joined: 11 Feb 2011 17:22

Re: PIC18F4620 Compiles but does not Run

#5 Post by MicroMark » 10 Oct 2014 20:36

The problem you are describing is usually a configuration setting.

Go to the "edit project" screen and check your oscillator settings. The 18f4620 is very different
than the 18f452 when it comes to the oscillator.

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#6 Post by amfortas » 12 Oct 2014 20:24

Thanks Mikromark,

Interestingly I have always used identical Osc settings at 4x8 PLL=32MHz with no problem for both 4620 and 452.

I have the added problem now that programs compile perfectly and run outside the IDS but the RUN menu will only access the debug options ! Cannot run anything in the IDS.

Re-installed from Mikroelectronica site and problems persist. Maybe something has stuck in the registry and not been cleared during uninstal.

Any ideas on this would be extremely welcome !

I appreciate your reply.

Regards,

Amfortas

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#7 Post by amfortas » 12 Oct 2014 22:55

Hi MaGik,

I have been wasting your time ! I was immersed in Delphi 7 and took on a totally wrong expectation for the MikroPascal RUN menu. Have reloaded the clean version which works fine although I still have to check out the PIC18F452/4620 issue.

Please accept y apologies !

Regards,

Amfortas

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

Re: PIC18F4620 Compiles but does not Run

#8 Post by filip » 13 Oct 2014 13:43

Hi,

Please, can you tell me more details of this issue that you are having, maybe attach a minimal project that demonstrates it ?

Regards,
Filip.

MaGiK
Posts: 897
Joined: 19 Apr 2013 10:00

Re: PIC18F4620 Compiles but does not Run

#9 Post by MaGiK » 13 Oct 2014 18:24

Hello amfortas :D

There are no need for any apologies :D
I'm glad that it worked out for you.
amfortas wrote:I still have to check out the PIC18F452/4620 issue.
Please let me and Filip know if that issue kept happening and do as Filip suggested so that we can try to help :D

Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#10 Post by amfortas » 19 Oct 2014 20:37

Thanks MaGik and Filip,

Still cannot compile 4620 successfully. Now I have lost my registration code for some unexplained reason and running my reg.exe does not restore registration even though I loaded latest version and registered a few days ago ! Awaiting a replacement key to hopefully get back to business.

I will get back once all is restored and if the 4620 problem remains. I have not used the debugger since I have always used "gotchas" to trace program bugs. Strangely the 4620 code compiles but simply hangs in one case where I use inline assembler which runs fine in the 452. I may be doing something crazy but had very few problems under XP. I wondered whether there ight be a bank switching issue with the 4620.

Very many thanks, I value your support which has put me right since I first purchased MMP !

Amfortas

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

Re: PIC18F4620 Compiles but does not Run

#11 Post by filip » 20 Oct 2014 12:21

Hi,

Please, can you tell me more details of this issue that you are having, maybe attach a minimal project that demonstrates it ?

As for the registration, I have replied to you on the other topic.

Regards,
Filip.

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#12 Post by amfortas » 20 Oct 2014 15:25

Hi Filip und Magik,

Having sorted out more of the Win8.1 insanities, I can isolate this code as functional in the 452 PIC and possibly not functional in the 462 PIC.

The code extracts data from an ADC register over an SPI link where I chose to use assembler because of various quirks in the Intersil ISL 26104 implementation such as different write and read modes and the need to verify ready-high to low transition.

The code reads data correctly in 452 but returns FF in 4260.



Function Get_Register(AD,Dummy:Byte): Byte;
{var R1:byte;}
begin
SSPCON1:=0;
SSPSTAT:=0x40; { 0 1 0 0 0 0 0 0 }
{ SMP = 0, CKE = 1}
SSPCON1:=0x31; { 0 0 1 0 0 0 1 0 }
{ CKP Idle Low. Clock Fosc/6}
SSPBUF:=AD; { Load Register Address Byte }
Chip_Select:=0;
{Delay_uS(100); }
ASM
{bcf Chip_Select} { Chip_Select =0 }
Char1: btfss SSPSTAT,BF { Check Address in SPI Buffer }
goto Char1
movf SSPBUF,W { If SPI Buffer full then discard }
clrf SSPBUF // Empty SPI Data Buffer
end;
SSPBUF:=Dummy; { Load Register Data Byte }
{Delay_mS(10); }
ASM
Char2: btfss SSPSTAT,BF { Check Data in SPI Buffer }
goto Char2
movf SSPBUF,W { If SPI Buffer full then }
clrf SSPBUF // Empty SPI Data Buffer
movwf _Res1 { pass Data to Res1 }
{bsf Chip_Select}
end;
Delay_uS(50);
Chip_Select:=1;
Result:=Res1;
end;


I do not know whether bank switching is an issue since native assembler does address acknowledging banks and since the inline assembler doe not provide bank switching instructions I have assumed that this is automatically dealt with.

The 4620 has larger memory to this might be the issue ?

Anyway now that the 4620 appears to run, I have a new ball game and much to explore !

I have been diverted by the impression that simple Library routines would run in the 452 and not the 4620 but I need to set up my EasyPIC6 again to switch beteen the two PICs, I have historic inline assembler running in both 452 and 4620 products. If you can see something in the above code which might not run in the 4620 that would be immensely useful.

Please do not spend much time on this. It is something which I must diagnose ! Win 8.1 simply trashes my XP fluency.

Best regards,

Amfortas

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: PIC18F4620 Compiles but does not Run

#13 Post by janni » 20 Oct 2014 21:50

amfortas wrote: I do not know whether bank switching is an issue since native assembler does address acknowledging banks and since the inline assembler doe not provide bank switching instructions I have assumed that this is automatically dealt with.
Nope :( .
The 4620 has larger memory to this might be the issue ?
No. Your assembly may work or not, whatever the processor, depending on where Res1 is placed and, if it's not in Access Bank, which memory bank is active just before you use this variable.

Simply make the assembly independent on banking. And, instead of using additional variable, move contents of W directly to result

Code: Select all

    //movwf _Res1 { pass Data to Res1 }
    movff WREG,Get_Register_local_result 
(You may need to add dummy assignment result:=result; to stop compiler from complaining.)

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#14 Post by amfortas » 20 Oct 2014 22:26

Thanks Janni,

Yes I just took pot luck with Res1 and accepted on the basis that it worked in the 452. I have to clear in my mind what you are saying but it seems a probable cause and certainly an error in my thinking.

I may not try things out for a day or too but I will come back hopefully with problem solved

Greatly appreciated !

Amfortas.

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: PIC18F4620 Compiles but does not Run

#15 Post by amfortas » 25 Oct 2014 01:09

Hi Janni,

This code still hangs using the 4620 runs fine in the 452 where I have 4 prototypes running.

Function Get_Register(AD,Dummy:Byte): Byte;
{var R1:byte;}
begin
SSPCON1:=0;
SSPSTAT:=0x40; { 0 1 0 0 0 0 0 0 }
{ SMP = 0, CKE = 1}
SSPCON1:=0x31; { 0 0 1 1 0 0 0 1 }
{ CKP Idle Low. Clock Fosc/64}
SSPBUF:=AD; { Load Register Address Byte }
Chip_Select:=0;
{Delay_uS(100); }
ASM
{bcf Chip_Select} { Chip_Select =0 }
Char1: btfss SSPSTAT,BF { Check Address in SPI Buffer }
goto Char1
movf SSPBUF,W { If SPI Buffer full then discard }
clrf SSPBUF // Empty SPI Data Buffer
end;
SSPBUF:=Dummy; { Load Register Data Byte }
{Delay_mS(10); }
ASM
Char2: btfss SSPSTAT,BF { Check Data in SPI Buffer }
goto Char2
movf SSPBUF,W { If SPI Buffer full then }
clrf SSPBUF // Empty SPI Data Buffer
movff WREG,Get_Register_local_result
end;
Delay_uS(50);
Chip_Select:=1;
{Result:=Res1;}
Result:=Result;
Result:=Result;
end;

There must be something very fundamental which I am missing !

I am sticking with the 18F452 just now since is has ample memory for my project. I really need to do more work on this to collect the information but working with the 452 is kind of attractive just now.

Best regards,

Amfortas

Post Reply

Return to “mikroPascal PRO for PIC General”