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 CCS Technical Support

Program halts when call to printf() to LCD is performed.

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



Joined: 25 Aug 2005
Posts: 65
Location: Huntington Beach, CA

View user's profile Send private message

Program halts when call to printf() to LCD is performed.
PostPosted: Mon Apr 17, 2006 10:34 am     Reply with quote

The following is code in-work. I have just added the LCD to the code. However, when I attempt to print to the LCD, near the end of the program, it appears to halt. Even the PWM output stops. This occurrs whether or not the LCD is connected or not. I have tried placing the lcd_init() in different locations but it has no effect. Any ideas?
Code:

#include <16F877A.h>
#device ICD=TRUE
#fuses HS,NOWDT,NOPROTECT,NOLVP
#device ADC=10
#use delay(clock=5000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
//#use rs232(debugger)
#define ld_reg_b (0x2000)
#define ld_a_update_ab (0x9000)
#define PUSH1 PIN_A5
#define PUSH2 PIN_A4
#define ampon PIN_C5
#define vref24 (0xd8)   // A/D reference set command and value
#define maxsel PIN_B1   // Low activates the D/A
#define maxclk PIN_B4   // D/A clock
#define maxdat PIN_B2   // D/A data
#include <lcd.c>

#int_ext
void int_ext_isr(void)
    {
    delay_us(15);
    }


   main()
   {
      long offset = 0;       //     01A6 in hex
      long refout = 845;       //     034D in HEX
      long const_off, const_ref;
      int refh,refl,offh,offl,chk_offh,chk_offl,chk_refh,chk_refl;
      long vref=0xd800;
      long chk_off,chk_ref,value;
      float check=345;  //just for testing the LCD output
      int i;
      //lcd_init();
      //delay_ms(15);
      output_high(PIN_B5);     //enable rs232 transceiver

****Many lines of code ommitted for clarity***

         //lcd_init();
         //delay_ms(15);

         while(1)    //This code starts a square wave and measures its ampltude after being processed
         {
         lcd_init();
         delay_ms(15);
            if(!input(PUSH1))
            {
               setup_ccp1(ccp_pwm);
               setup_timer_2(T2_DIV_BY_1, 66, 2);
               set_pwm1_duty(33);
               setup_adc_ports(AN0_AN1_VSS_VREF);
               setup_adc( ADC_CLOCK_INTERNAL );
               set_adc_channel( 0 );

               while (!input(push1))
               {                 
                  //printf("Push yes\n\r");      //This section will be expanded
                  enable_interrupts(int_ext);
                  enable_interrupts(global);
                  EXT_INT_EDGE(H_to_L);
                  value = Read_ADC();
                 
               }
               setup_ccp1(CCP_OFF);
            }
               else
               {
                  setup_ccp1(CCP_OFF);
                  //printf("No push\n\r");
                  //printf("value = %04XL\n\r", value);
                  //printf(lcd_putc,"\fvalue  %4.3f", check);    //If this line is activated the program hangs

               }
         }
   }
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 17, 2006 10:45 am     Reply with quote

Make a little program to test LCD init and basic functionality. Perhaps
the code is stuck waiting for the LCD to respond.

This test program will say if the problem is in the LCD module or the mix of the LCD and the rest of your program.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Mon Apr 17, 2006 11:15 am     Reply with quote

Just to add to treitmey's response.....

The standard lcd driver that comes with CCS and that can be found on the board here uses handshaking to communicate with the lcd. The lcd module will assert data7 high while it is busy, and the code waits while this is the case. [I think.....check into it.....doing this from memory]

It sounds like your code is getting stuck at that point. Things to check for are the physical connection to the lcd, and whether you used #use fast_io() for the port(s) your lcd is connected to.
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