| View previous topic :: View next topic |
| Author |
Message |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Tue Apr 20, 2010 1:39 pm |
|
|
| MikeP wrote: | | What version of Proteus are you using ? The cof file work fine here. I use version 7.7 SP1. |
I am using 7.5 sp3.
So these COF files really work on Proteus ?
You wired a potentiometer to pin RA0 and the output of the conversion was on Port B ? Because I got no result of my simulation, no output and no change in the registers.
Okay listen, can I write a program and ask you to simulate it on your Proteus and tell me if it worked ?
It will save me a lot of time .....please  |
|
 |
MikeP
Joined: 07 Sep 2003 Posts: 49
|
|
Posted: Tue Apr 20, 2010 10:03 pm |
|
|
| Sure I will try it |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Thu Apr 22, 2010 8:04 am |
|
|
| MikeP wrote: | | Sure I will try it |
okay thx, but I need to ask
You copied my code into pic c compiler and then you clicked on build all , and took the "cof" files generated and applied it into a pic18f4331 on Proteus, right??
I am just asking to see if I did anything wrong. Perhaps I can make a successful simulation. |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Fri Apr 23, 2010 12:21 am |
|
|
Guys I need some help.
First of all, someone told me about an MPLAB environment in my pic c compiler.
How do I get that ????
And if I compiled my code and it worked, and I want to burn it using pickit programmer, which file I should use ??
My friend has a programmer that he built himself. I need to know if the programmer is for 16f, will it also work for 18f ? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Apr 23, 2010 12:46 pm |
|
|
ISIS 7.5 sp3 works perfectly with CCS. You need to add CCSC in the Code Generation Tools
and to have ccscoff.exe in the same path.
Regarding this project, I guess that you have done an very optimistic evaluation in its
realization, which is not bad but in this case is quite dangerous.
I hope not offend you, is needed to have skills and enough knowledge, before using these
tools to engage in this kind of project.
Humberto
To to go upstairs a ladder, you must step on the first stair, then the second and so on.. |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Fri Apr 23, 2010 2:38 pm |
|
|
Thx for the reply, look, I am not going to start directly in a 1500 watts motor but I need to start from somewhere, and a successful simulation is my first step.
Anyway how can I add CCSC in the code generation tools and have ccscoff.exe in the same path ?? Please help. |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Apr 23, 2010 6:29 pm |
|
|
OFF TOPIC
---------------------------------------------------------------------------
Source >>> Define Code Generation Tools
Click in Browse and search and the path for "CCSC.exe"
Make rules:
Source Extn: C Obj Extn: HEX
Command Line: %1 +DF +FM +P1
Debug Data Extraction
List File Extn:COF
Click in Browse and search and the path for "ccscoff.exe"
---------------------------------------------------------------------------
Humberto |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Sat Apr 24, 2010 12:02 am |
|
|
| Can I have a more specific explanation because actually I didn't get it. |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Apr 24, 2010 6:44 am |
|
|
-------------------------------------------------------------------------------------
In the ISIS electronic design suite screen, click the label Source and select
Define Code Generation Tools, a new window will open. In it you will see
3 configuration options:
-a) Code Generation Tool
| Quote: |
Tool: CCSC
Browse and search the path
Path: C:\Program Files\PICC\Ccsc.exe
|
-b) Make rules
| Quote: |
Source Extn: C
Obj Extn: HEX
Command Line: %1 +DF +FM +P1
|
-c) Debug Data Extraction
| Quote: |
List File Extn:COF
Browse and search the path for "ccscoff.exe"
|
-------------------------------------------------------------------------------------
You could understand that we can not start teaching how to use these tools in this forum.
If you want to learn Proteus, MPLAB, etc, start by reading the manual and visit it forums to learn and ask questions.
There are very good tutorials to help you learn and I suggest to start with a simple and easy project.
Good luck.
Humberto |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Sat Apr 24, 2010 2:38 pm |
|
|
hello, thx for the help.
This project is my final project, so i don't have a choice.
I have used mplab and Proteus before but only for minor projects, this is the first time I program in C language.
Anyway, I have done what you said but the program is apparently not working, maybe it's a problem from the code and not from Proteus
Can someone try to simulate this to check it?
If it's working on your PC then there's a problem with my Proteus, if not then my code is not right.
main.c
| Code: | #include "D:\Documents and Settings\elee\My Documents\pwm\main.h"
void main()
{
int1 done;
int16 value;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0|ADC_CONT_A|ADC_WHEN_INT0|ADC_INT_EVERY_OTHER);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
// TODO: USER CODE!!
set_tris_a(0xff);
setup_adc_ports (all_analog);
set_adc_channel (0);
setup_adc(ADC_CLOCK_INTERNAL);
read_adc(ADC_START_AND_READ);
done = adc_done();
while(!done) {
done=adc_done();
}
value = read_adc();
OUTPUT_B(value);
}
|
main.h
| Code: |
#include <18F4331.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV27 //Brownout reset at 2.7V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOWINEN //WDT Timer Window Disabled
#FUSES T1LOWPOWER //Timer1 low power operation when in sleep
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
//PWM module high side output pins have active high output polarity
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
//PWM module low side output pins have active high output polar
#FUSES NOPWMPIN //PWM outputs drive active state upon Reset
#FUSES MCLR //Master Clear pin enabled
#FUSES FLTAC1 //FLTA input is multiplexed with RC1
#FUSES SSP_RC //SCK/SCL=RC5, SDA/SDI=RC4, SDO=RC7
#FUSES PWM4B5 //PWM4 output is multiplexed on RB5
#FUSES EXCLKC3 //TMR0/T5CKI external clock input is muliplexed with RC3
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
|
|
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Apr 24, 2010 7:09 pm |
|
|
Your test program is too complicated. All you want to do is read the ADC
(on pin AN0) and output it to PortB. The following program will do that:
| Code: |
#include <18F4331.h>
#device adc=8
#fuses INTRC_IO,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=8000000)
//===========================
void main(void)
{
int8 result;
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_4);
set_adc_channel(0);
delay_us(10);
while(1)
{
result = read_adc();
output_b(result);
delay_ms(100);
}
} |
|
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Sun Apr 25, 2010 1:52 am |
|
|
| PCM programmer wrote: | Your test program is too complicated. All you want to do is read the ADC
(on pin AN0) and output it to PortB. The following program will do that:
| Code: |
#include <18F4331.h>
#device adc=8
#fuses INTRC_IO,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=8000000)
//===========================
void main(void)
{
int8 result;
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_4);
set_adc_channel(0);
delay_us(10);
while(1)
{
result = read_adc();
output_b(result);
delay_ms(100);
}
} |
|
still , in proteus i cant see anything on port B , i have linked all 8 pins of port b to a led and ground and nothing on the output
i will do my project alone , my real problem is how to make a successful simulation on proteus for my code in order to make sure it's working ....
and untill now no simulation is working despite the fact that the program is really small
ADRESH and ADRESL are not changing and the value of port B is always the same 0b01011001
and i am getting this repeating message in the simulation log
pc=0x0000. $MCLR$ is low . processor in is reset |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Sun Apr 25, 2010 3:05 am |
|
|
finally it's working
i had to connect the MCLR pin (which i know nothing about) to the supply...
i googled the message and gave me a link to this forum , and it's solved
thx guys , finally i can start my program |
|
 |
wewe
Joined: 17 Apr 2010 Posts: 31
|
|
Posted: Sun Apr 25, 2010 3:40 am |
|
|
| Code: | #include "D:\Documents and Settings\elee\My Documents\New Folder\my main.h"
void main()
{int8 result;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0|ADC_CONT_A|ADC_WHEN_INT0|ADC_INT_EVERY_OTHER);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_4);
set_adc_channel(0);
delay_us(10);
setup_power_pwm_pins(PWM_COMPLEMENTARY, PWM_COMPLEMENTARY, PWM_OFF, PWM_OFF);
while(1)
{
result = read_adc();
setup_power_pwm(PWM_CLOCK_DIV_4,1,0,199,0,1,5);
set_power_pwm0_duty(result)};
} |
the simulation is not working , the analog to digital conversion is working right but there's no pwm outputs
and btw proteus is marking that 3 pins are giving a dc output
the pins are RC5 /int2/sck/SCL
rc6/TX/CK/SS
rc7/rx/td/sdo
Last edited by wewe on Sun Apr 25, 2010 3:00 pm; edited 2 times in total |
|
 |
|