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 gets stuck in printf I want to simulate code

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








MPLAB gets stuck in printf I want to simulate code
PostPosted: Fri Sep 24, 2004 9:43 pm     Reply with quote

Code:
#define START   PIN_B0
#define SIN   PIN_B1
#define LOAD   PIN_B2
#define RESET   PIN_B3
#define XCK   PIN_B4
#define READ   PIN_B5



const char maskData = 0b10000000;  //mask out the last bit to be shifted in data
const char maskAdr = 0b00000100;  //mask out the last bit to be shifted in adr


void setDefalts(void)
{
//SET DEFALTS
   output_low(START);  //start=low
   output_low(SIN);  //sin.data=low
   output_low(LOAD);  //load=low
   output_high(RESET); //reset=high
   output_low(XCK);  //Xck=low
}


void resetCam(void)
{
   output_low(RESET);     //pull reset low
   output_high(XCK);    //pull Xck high
   output_high(RESET);    //pull reset high
   output_low(XCK);     //pull Xck low
}

void resetCamDelay(void)//same as reset camera except delays so you can see it.
{
   delay_ms(1000);
   output_low(RESET);     //pull reset low
   delay_ms(1000);
   output_high(XCK);    //pull Xck high
   delay_ms(1000);
   output_high(RESET);    //pull reset high
   delay_ms(1000);
   output_low(XCK);     //pull Xck low
   delay_ms(1000);
}



void loadReg(char reg)
{
   output_bit(SIN,reg & maskAdr);   //mask first bit of the adress and output
   output_high(XCK);                //clock data in
   output_low(XCK);

   reg=reg<<1;                         //shift left
   output_bit(SIN,reg & maskAdr);   //mask first bit of the adress and output
   output_high(XCK);                //clock data in
   output_low(XCK);

   reg=reg<<1;                         //shift left
   output_bit(SIN,reg & maskAdr);   //mask first bit of the adress and output
   output_high(XCK);                //clock data in
   output_low(XCK);
}


void loadData(char data)
{
   output_bit(SIN,data & maskData);    //mask first bit of the data and output
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);      //output 2nd bit
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);      //output 3rd bit
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);      //output fourth bit
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);      //output fifth bit
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);      //output 6th bit
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);    //output 7th bit
   output_high(XCK);                   //clock data in
   output_low(XCK);
   data=data<<1;                            //shift left
   output_bit(SIN,data & maskData);    //output 8th bit
   output_high(XCK);                   //clock data in
   output_high(LOAD);                   //load register
   output_low(XCK);
   output_low(LOAD);
}

void startCam(void)
{//START SEQUENCE
   output_high(START);    //pull start up
   output_high(XCK);    //pull clock up
   output_low(START);     //pull start low
   output_low(XCK);     //pull clock low
}

Code:
#include <16F877A.h>
#device adc=8
#use delay(clock=20000000)
#fuses HS, NOWDT, NOLVP, BROWNOUT//never trust the wizard gizmo
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7)
#USE DYNAMIC_MEMORY//this could gain memory back after the function is over.
#include "C:\WINDOWS\Desktop\camera\GBCamera.h"
#ZERO_RAM

#int_AD
AD_isr()
{

}



void main()
{
int i= 1;


   port_b_pullups(TRUE);
   setup_adc_ports(RA0_ANALOG);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_AD);
   enable_interrupts(global);

while(TRUE)
{

setDefalts();
resetCam();

loadReg(0);
loadData(128);

loadReg(1);
loadData(6);

loadReg(2);
loadData(1);

loadReg(3);
loadData(85);

loadReg(4);
loadData(1);

loadReg(5);
loadData(0);

loadReg(6);
loadData(0);

loadReg(7);
loadData(33);



startCam();
printf("lets hope this works");
while(0==input(READ)); //ENDLESS LOUP TILL READ GOES HIGH


}//END OF ENDLESS LOOP

}//END OF MAIN
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Sat Sep 25, 2004 3:20 am     Reply with quote

As I told you before, you CAN NOT step through printf. Set a breakpoint on the statement right after the printf and run the code. You'll see it will run just fine. If you try to step through it, the timing of the internal UART gets messed up and nothing/junk will be transmitted. In the case of nothing going out of the port, it will appear that the simulator is stuck.
Guest








No I can not get to the wile loop after printf w breakpoint.
PostPosted: Sat Sep 25, 2004 11:52 pm     Reply with quote

No I can not get to the wile loop after printf with a breakpoint.
Mistress Z
Guest







Teague would never do such a t
PostPosted: Sat Mar 26, 2005 12:50 pm     Reply with quote

As Chrissy skipped ahead of me I counted out the bills in my hand Windriver Ghost. Chrissy had rolled over onto her stomach seemed on the verge of nodding off 3d Pacman. Long fake eyelashes were added and a heavy coat of mascarra applied, followed with the eyeliner Ossp Str. I began to nibble at her earlobe as I withdrew and sunk in again I18nhtml. Her little girl cotton [spam] were atop the heap I picked everything up and headed for the bathroom Rockrun.
bluetooth



Joined: 08 Jan 2005
Posts: 74

View user's profile Send private message

Re: No I can not get to the wile loop after printf w breakpo
PostPosted: Sat Mar 26, 2005 1:06 pm     Reply with quote

Anonymous wrote:
No I can not get to the wile loop after printf with a breakpoint.


To get around this problem, just put a "dummy" instruction after the printf, like maybe

i=0;

you can set your breakpoint there.
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