Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ISIS PWM 16F877 problem ?

Status
Not open for further replies.

UnLoCo

Newbie level 2
Joined
Jun 19, 2009
Messages
2
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
monastir
Activity points
1,290
Hello guys
I'm testing a simple CCS program on ISIS.
I'm using a pic16F877 (20MHZ)
it compiles fine but no PWM is shown in ISIS.
i know the problem is on ISIS because i had a similar prog running fine on hardware.
has anybody managed to show PWM on isis from a 16f877 ?
thanks a lot.
Code:
//#include "speed control.h"
#include <16F877.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use rs232(baud=9600,parity=N,xmit=PIN_D0,rcv=PIN_D1,bits=8,stream=DEBUG)

#define Delay 1

#int_RDA
void  RDA_isr(void) 
{

}



void main()
{
   char com,spd,pos,val;
   signed int16 diff;
   setup_adc_ports(AN0_AN1_AN3);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   setup_timer_2(T2_DIV_BY_16,255,1);
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(50);
   // TODO: USER CODE!!
   while(1){
      set_adc_channel(1);
      delay_ms(Delay);
      com = read_adc();
      delay_ms(Delay);
      set_adc_channel(0);
      delay_ms(Delay);
      spd = read_adc();
      diff = com - spd;
      if(com > spd){pos='+';val=diff;}
      else{pos='-';val=~diff;}
      fprintf(DEBUG,"%c",pos);
      fprintf(DEBUG,"%u\r",val);
      delay_ms(Delay);
      delay_ms(300);
   }

}

ISIS simulation file
 

Attachments

  • speed control.zip
    20.7 KB · Views: 51

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top