Jump to content
Sign in to follow this  
Micmar

Pic12Lf1822 Simulation Fail (Basic)

Recommended Posts

hello

 

I have wrote a little program to test the comparator and change two output

Report: of simulation

PA2 work well

PA5 not work

comparator not work

in attachement the program.

 

PS in tha "basic" ide I am unable to work with the autocompletion

 

Thanks in advance for your attenction. Best regards, Marco

t1.zip

Share this post


Link to post
Share on other sites

Micmar,

I have wrote a little program to test the comparator and change two output

Report: of simulation

PA2 work well

PA5 not work

Still looking into this one, it's not straight forward.

 

Regards

Dave

Share this post


Link to post
Share on other sites

I have found in your code a number of small problems.

I'm not sure whether these do affect on the simulator but certainly they do on the real hardware.

 

1) The following pragma line is wrong:

 

 'System Config2 W_PROT_OFF, PLLX4_DISABLE,STAK_OVF_RESET
#pragma DATA  _CONFIG2,  _WRT_OFF & _PLLEN_OFF, _STVREN_ON

 

You should remove the comma before _STVREN_ON and replace it with & (ampersand).

In different words it becomes:

 

'System Config2 W_PROT_OFF, PLLX4_DISABLE,STAK_OVF_RESET
#pragma DATA  _CONFIG2,  _WRT_OFF & _PLLEN_OFF & _STVREN_ON

 

 

2) Enabling the global and peripheral interrupts is needed but not enough. The Comparator interrupt must be enabled in order to make your code to work as expected. You need to add somewhere in your code the line - after the line set_bit(intcon,GIE) is a good place - :

 

  set_bit(pie2, C1IE)	 'enable comparator C1

 

 

3) In your code the line #pragma CLOCK_FREQ 1000000 makes me thinking you want 1MHz for the internal oscillator to setup. If that's the case then you should add the line at the very first instruction of your code:

 

 osccon = 0x58 ' set oscillator register control to 1MHz

 

Please note that the internal oscillator frequency is set to 500KHz by default if you don't change osccon.

The #pragma CLOCK_FREQ is only used to generate the correct delays in the delay instructions.

Share this post


Link to post
Share on other sites

Hello Ettore

 

Thanks for your help.

This time I did more tests, and placed the errors you have reported to me, this ide is totally new for me, but I continue to have problems.

In the simulation PA4 output remains set also writing trisa4 = 1 and port 5 does not change status. The PA3 that is only an input is always seen output.

But the strangest thing is that I can not do the flashing LED on the board, while in simulation works, but doing the program with the old basic compiler that I want to replace, because it has no built-in simulator, the LED flashes.

I'm pretty disappointed in this.

 

Happy Easter and thanks again, Marco

Share this post


Link to post
Share on other sites

Micmar,

Micmar,

I have wrote a little program to test the comparator and change two output

Report: of simulation

PA2 work well

PA5 not work

Still looking into this one, it's not straight forward.

The problems here are two:

1) Error in the PIC16 Ext simulator that does not allow connection to the correct pin.

2) Errors in .TDF that list the names associated with each pin.

 

These will be fixed in the next release,

 

Regards

Dave

Share this post


Link to post
Share on other sites

Hello

 

I have tested the simulator with the 7.10 release but it fail again :( :( :(

Can youn fix this? I work strong with this family

 

Thanks and Regards, Marco

Share this post


Link to post
Share on other sites

Micmar,

Hello

 

I have tested the simulator with the 7.10 release but it fail again :( :( :(

Can youn fix this? I work strong with this family

What exactly is not working?

I ran the program you posted at the beginning of this thread and it seemed to work - well PA5 is working.

Does this work for you?

 

 

Regards

 

 

Dave

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×