Jump to content

jetster94

EstablishedMember
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral

About jetster94

  • Rank
    Newbrie
  1. Finally I managed to make the lcd work. The infinite loop in lcd_setup is inherent to the constant declaration. When setting use busy, the busy signal is not simulated by the debugger so it is still wait for a not busy state. So in order to simulate a lcd properly, you have to set use time delays and then switch to use busy when implementing on the PIC. Hope to see you guys with another issue !!
  2. I don't really get what you mean. When I launch the program, each lines of the execution section are executed, line by line, and the registers are storing all expected values. That's why I don't believe my code is equal to an unedited main function. I don't understand why, when the program enters the lcd_setup() function, it is never going out from it in order to execute the following instructions such as lcd_clear(), lcd_gotoxy(), etc... Regards
  3. Changing adcon was a good idea, but the debugger still runs lcd_setup in an infinite loop. Did anyone try to simulate this?
  4. Hi, I'm back with a new deadly issue. I'm trying to drive a lcd with a PIC16F873. #include <system.h> #define LCD_ARGS 1, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \ 1, /* Use busy signal: 1 = use busy, 0 = use time delays */\ PORTC, TRISC, /* Data port and data port tris register */ \ PORTA, TRISA, /* Control port and control port tris register */ \ 1, /* Bit number of control port is connected to RS */ \ 3, /* Bit number of control port is connected to RW */ \ 2 /* Bit number of control port is connected to Enable */ #include <lcd_driver.h> Until now, every thing is ok, then things are getting complicated... const unsigned char hello[6]={'H','E','L','L','O',0x00}; void main (void) { trisb = 0xFF; //configure port B trisa = 0x00; trisc = 000000b; spbrg = 25; txsta = 0x26; rcsta = 0x90; adcon0 = 0; porta = 0x00; //clear port A lcd_setup(); lcd_clear(); lcd_gotoxy(0,0); lprintf(hello); } This simple program just displays "hello" on the lcd screen. Result = nothing happens on the lcd. I launched the debugger to see what's actually happening in register and to my great surprise, the lcd_setup just runs in an infinite loop... I'm using PORTC as the data port for lcd AND I'm also using PORTC for serial transmission. Do you know if it is possible to use both functionality?
  5. Hi ! Before looking for a place in a graveyard I 'd require your help about a common and meaningless error : missing semicolon. The program was working perfectly UNTIL I added this lcd_setup function. #include <system.h> #define LCD_ARGS 2, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \ 1, /* Use busy signal: 1 = use busy, 0 = use time delays */\ PORTC, TRISC, /* Data port and data port tris register */ \ PORTA, TRISA, /* Control port and control port tris register */ \ 1, /* Bit number of control port is connected to RS */ \ 2, /* Bit number of control port is connected to RW */ \ 3, /* Bit number of control port is connected to Enable */ #include <lcd_driver.h> char read; void main() { trisb = 0xFF; trisa = 0x00; trisc = 000000b; spbrg = 25; txsta = 0x26; rcsta = 0x90; adcon0 = 0; porta = 0x00; //clear port A lcd_setup(); //<===== error missing semicolon points here //lcd_write('Hello\0'); while(1) //endless loop { The source after while(1) has not been modified. Thanks for your help!
  6. Thanks a lot Dave for your advice. This had solved the condition testing problem. I used to write && for bit masking in LabWindows CVI, such differences may arise when using different compilers, this will be an excellent thing to bear in mind in the future. Anyway, I maintain the bug concerning portA register and led block failure in debugger mode.
  7. Bug description: When using a switch/case structure or if/ else if structure, the code seems to be executed regardless of the inputs. Steps to reproduce: Here is the code source. A simple program that performs a LED flashing on port A according to the word presented on port B. #include <system.h> char read; void main() { trisb = 0xFF; //configure port B trisa = 0x00;//configure port A spbrg = 25; // Asuart config for future apps. txsta = 0x26; rcsta = 0x90; #ifdef _PIC16 porta = 0x00; //clear port A #endif while(1) //endless loop { read=(portb&&0x03); //bit mask for the two LSB switch (read) { case 0x00 : //flash led with long period porta=0x01; delay_s(1); porta=0x00; delay_s(1); break; case 0x01 : //flash LED with short period porta=0x01; delay_ms(50); porta=0x00; delay_ms(50); break; case 0x03 : //flash LED with intermediate periode porta=0x01; delay_ms(200); porta=0x00; delay_ms(200); break; } } } Expected behaviour: It is obvious that the program should be considering the two LSB only. However, the case 0x01 is true even if the word 0x04 is presented ! When 0x03 is presented, the case 0x01 is true and therefore the break instruction sends the PC to the while instruction. Is the problem 100% reproduceable: This problem reproduces every time, even after reinstalling the software or restarting computer. The debugger AND the PIC are behaving in the same way. IDE version: SourceBoost IDE version 6.20 Compiler: Boost C Compiler version: Compiler version 6.20 Target device: PIC16F873 OS: WinXP Comments: When using PIC16F873 as the target device, the LED block linked to port A does not copy the port A state. Moreover, the port A register does not change value (0x00 remains) even if the instruction "porta=0x01" had been executed. When using another target device, the port A (register and associated led block) is behaving normally but the condition testing problem remains
  8. Hi ! I've just written a simple program using PIC16F873. Configuring port b as input and port a as output, my program is using a switch/case structure. First, the bit masking does not seem to work properly when written in that way. Secondly, even if I present 0x03 on port b, the "case 0x01" is being executed anyway. Note that the first case 0x00 works properly. The debugger is also behaving in that "strange" way. COuld you please help me? Thanks!! --------------------------- void main() { trisb = 0xFF; //configure port B trisa = 0x00; spbrg = 25; txsta = 0x26; rcsta = 0x90; #ifdef _PIC16 porta = 0x00; //clear port A #endif while(1) //endless loop { read=(portb&&0x03); switch (read) { case 0x00 : porta=0x01; delay_s(1); porta=0x00; delay_s(1); break; case 0x01 : porta=0x01; delay_ms(50); porta=0x00; delay_ms(50); break; case 0x03 : porta=0x01; delay_ms(200); porta=0x00; delay_ms(200); break; } } }
×
×
  • Create New...