CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

mplab sim vs proteus in pic16f88

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
elphi



Joined: 17 Apr 2007
Posts: 20
Location: tijuana,bajacalifornia,mexico

View user's profile Send private message MSN Messenger

mplab sim vs proteus in pic16f88
PostPosted: Tue Apr 17, 2007 8:21 am     Reply with quote

Hi, I’ve written the code below, it is a sine wave generator, this generator, must work with three different frequency , (this is a requirement in my project, witch actually is a project for my company).
It seems to work correctly, it must work correctly, but I have a doubt, I’ve simulated it in MPLAB SIM toll, and with the stimulus controller, I send the pulse to activate the external interrupt en RB0, an it works fine, but when I build the circuit in PROTEUS © (I don’t have the chip because I’ve just requested it) it doesn’t work, it just give the first frequency proposed.
Then my question is (finally), In witch simulator I have to trust MPLAB SIM or PROTEUS.
And please don’t tell me that I must build the circuit hardware ;).


Code:

#include "16f88.h"
#include <stdlib.h>
#include"limits.h"
#define RETURN_HOME 0x2
#fuses NOWDT,XT, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, DEBUG, NOPROTECT, FCMEN, NOIESO
#use delay(clock=8000000)
#use fast_io(B)
int l=1,f=7,i,sine[40]={32   36   40   46   50   52   56   58   60   62   62   62   60   58   56   52   50   46   40   36   32   26   22   16   12   10   6   4   2   0   0   0   2   4   6   10   12   16   22   26};

#INT_EXT
void ext_isr()
{
switch (f)
   {
      case 4:///////////////4 + 6.5 del pic = 10.5us * 40 (steps) = 420 us = 2380.952 hz close to 2450 hz
      f=7;break;
      case 7://///////////// 7+ 6.5 del pic = 13.5us * 40 (steps) = 540 us = 1851.851 hz close to 1880 hz
      f=19;break;
      case 19://////////////19+ 6.5 del pic = 25.5us * 40 (steps) =1020 us = 980.3921 hz close to 1000 hz
      f=4;break;
   }
}


void main()
{
   port_b_pullups(TRUE);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ);
   setup_cpp1(CCP_OFF);
   setup_counters (RTCC_INTERNAL,RTCC_DIV_2);
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);
   EXT_INT_EDGE(0,L_TO_H);
   SET_TRIS_b(0x1);
   SET_TRIS_a(0x00);
   while (true)
   {
      for(i=0;i<39;i++)
      {
         output_b(sine[i]);
         delay_us(f);
      }
  }
}

_________________
Every little thing gonna be alright
elphi



Joined: 17 Apr 2007
Posts: 20
Location: tijuana,bajacalifornia,mexico

View user's profile Send private message MSN Messenger

Re: mplab sim vs proteus in pic16f88
PostPosted: Tue Apr 17, 2007 9:31 am     Reply with quote

Sorry, ive just noticed that PROTEUS send me a message telling me that TRISB and TRISA instructions are deprecated.

I suppose that I have to build the circuit in my protoboard, (when a get it).
_________________
Every little thing gonna be alright
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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