Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

simple C programing for 16f628a what am I missing

Status
Not open for further replies.

sagitis

New Member
Hi, I've started to learn programming mircocontrollers due to work school project. I started to learn basic from Nigel's page, yes it was a great introduction but only if I have more time......

However due to work loads and co-operation with partners I need to fall back to C programming using mikroC (more structural and easy for others to understand) . We've got simple mathematic functions done high low add minus blah. Now we Have arrive to the state to program the LCD controller. If just follow the mikroC C example and set it would probably be straight forward, but we don't want to make our project is copying people so we decide to to go for internal oscillation.

Now the problem strike us is which device flag(configuration fuses) should be turned on. According to nigel code it was _config0x3D18 which is 0011 1101 0001 1000(binary) so is this relfecting
bit 13 flash mem protection off
how ever bit 12 is undefined why 19 is 0 ?
bit 8 CPD 1 code protection off
bit 7 0 for VPP
bit 6 0 reset disable
bit5 0 digital input
bit 4 1 (I don;t knwo here) ( i think this is where we set the clock for our lcd is external or internal
bit 3 1 power up timer disable)
Bit 2 wdt 0 (if we are making a real time clock this will be 1, right ? another function is need to prevent it loops without sopping right)

oh besides this is example code from mikroC

Code:
char *text = "mikroElektronika";

void main() {
  TRISB = 0;
  LCD_Init(&PORTB);         // Initialize LCD connected to PORTB

  LCD_Cmd(LCD_CLEAR);       // Clear display
  LCD_Cmd(LCD_CURSOR_OFF);  // Turn cursor off
  LCD_Out(1,1, text);       // Print text to LCD, 2nd row, 1st column
  Delay_ms(1000);
  LCD_Out(2,6,"mikroE");
}//~!j

not sure how to paste mikroC schmetic
 
Last edited:
mikroC GUI allows you to set/clear the configuration bits easily. If you clicked Project->Edit, you've seen a list of flags. _INTRC_OSC_NOCLKOUT selects the internal oscillator (with assembly you would set bit 4,1,0 of the configuration word to 1-0-0). Remember that you have to specify fosc with mikroC.
 
sagitis said:
bit 4 1 (I don;t knwo here) ( i think this is where we set the clock for our lcd is external or internal
Refer to the datasheet, under special features of the microcontroller. Bit 4, 1 and 0 are supposed to be setting the oscillator type right?
 
thanks for the reply guys, I re-read what I have written this morning. It was so incomprehensible, I should have told myself not to post while half asleep.

@BananaSongi yeah I have referred to the data sheet didn't understand how come a number binary 1,0 can represent 4 different clock state.

@eng1 yeah I clicked the _INTRC_OSC_NOCLKOUT and other options but the LCD, only show boxes in the first line (electus LCD , uses Hitachi controller).I try and set the setting to default which is WDT off LVP off HSspeed oscilation ON _INTRC_OSC_NOCLKOUT ON, but the LCD is not showing the example code. Don't really know where have i gone wrong. I made the connection correctly according to mikroC example HW configuration.


My colleague got theirs work but they put the Vpp pin on high, (which is totally weird, since he uses mikroC standard library code and the LCD 4 bit module is only to deal with portB) I guess he is lying to me or it is a fluke, or he doesn't want to help since most of us couldn't get the LCD to work.

argh project due soon DIES...........thanks in advance for the inputs. Things might be easier if started off as basic like everyone here stupid project communication and co-ordination mark.
 
thnaks finally problem solved it should be _INTOSC_OSC_NOCLKOUT ON, and mikroC put mclr pin on automatically. NO wonder he have to put pin 4 high

Now only real time clock left, interrupt interrupt ............
 
Status
Not open for further replies.

Latest threads

Back
Top