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.

I need help again

hassanmahmoud

New Member
I made a new project with the 16C73B microcontroller, but when adding the words, the random memory was not enough, so I added the EEPROM, but I had difficulty adding the words to the EEPROM 24C08B.
And I use Micro C program.
Thank you for all the help you give me

1.PNG

Code:
// Lcd pinout settings
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D4 at RB4_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D7_Direction at TRISB7_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB4_bit;

     // I want save this (words) in EEprom  "24C08B" ?
char txto[] = "ok";
char txtg[] = "welcom";
char txtf[] = "thanks";
char txtn[] = "No Information";
char txtr[] = "Ready";                  //Ready Test
  //  // I want save this (words) in EEprom  "24C08B" ?

void main()
    {
     trisa.f0=1;
     trisa.f1=1;
     trisa.f2=1;
     trisa.f3=1;
     trisa.f4=1;
     trisa.f5=1;
     trisa.f6=1;
     trisa.f7=1;
     porta=0;


    Lcd_Init();                        // Initialize LCD

    Lcd_Cmd(_LCD_CLEAR);              // Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

    Lcd_Out(1,6,"Welcome");           //  "welcome"
    Lcd_Out(2,1,"Test");
    delay_ms(2000);
    Lcd_Cmd(_LCD_CLEAR);


     while(1)                   // <-- Need a forever loop here
        {

        if(porta==0b0000000)        //  test your money
            {
            Lcd_Out(1,7,txtr);
            Lcd_Out(2,2,txtt);
            delay_ms(500);
            Lcd_Cmd(_LCD_CLEAR);
            }

        }


    }
 
The 16C73 is an antique OTP device, the datasheet is dated 1998 :D

However, it has a reasonable amount of program memory (4K) so is more than ample for your program - but it is VERY lacking in GPR's (RAM), only 192 bytes.

You can't add external program memory, or GPR's to most PIC's - you can add external storage, but you need to write routines to upload and download the data over the I2C bus to the EEPROM, but you don't have any I2C routines in the code above.

I would strongly suggest you get a more modern device, that is electronically reprogrammable, vastly higher spec, and vastly cheaper.
 
Hi Mike. In proteus they have built in I2C and SPI analysers the trigger is for that purpose.

hassanmahmoud You can put those lines in a text file and attach it to the device.

if you make a file type those lines ( don't forget the zero terminator ) and rename to "yourtxt.bin"

you can read them...

However!! as they are constants! just place them in code memory.
C:
const char txto[] = "ok";
const char txtg[] = "welcome";
const char txtf[] = "thanks";
const char txtn[] = "No Information";
const char txtr[] = "Ready";
 
The 16C73 is an antique OTP device, the datasheet is dated 1998 :D

However, it has a reasonable amount of program memory (4K) so is more than ample for your program - but it is VERY lacking in GPR's (RAM), only 192 bytes.

You can't add external program memory, or GPR's to most PIC's - you can add external storage, but you need to write routines to upload and download the data over the I2C bus to the EEPROM, but you don't have any I2C routines in the code above.

I would strongly suggest you get a more modern device, that is electronically reprogrammable, vastly higher spec, and vastly cheaper.
I know that, but I build my projects with microcontrollers available in my country, and they are only 3 types. The best of them is 16F877, but it is large in size and has many terminals, 40 terminals, and this does not suit my projects.
PIC recommended to me the number of limbs from 18 to 20 limbs and he has a large memory that can accommodate at least 20 words.
 
Hi Mike. In proteus they have built in I2C and SPI analysers the trigger is for that purpose.

hassanmahmoud You can put those lines in a text file and attach it to the device.

if you make a file type those lines ( don't forget the zero terminator ) and rename to "yourtxt.bin"

you can read them...

However!! as they are constants! just place them in code memory.
C:
const char txto[] = "ok";
const char txtg[] = "welcome";
const char txtf[] = "thanks";
const char txtn[] = "No Information";
const char txtr[] = "Ready";
My friend, I want to put 15 more words in memory, but it does not fit, so I thought of adding an EEPROM because many people use this method and put a lot of other information and pictures in it.
 
BTW. One thing you MUST do when using Proteus, the pullups have to be digital. They do not simulate with analoue types. in the library type pullup and use that.

There is 4K of program memory.. I doubt you will use THAT much code.

16 chars per message is only 240 bytes for all 15 messages..
 
I know that, but I build my projects with microcontrollers available in my country, and they are only 3 types. The best of them is 16F877, but it is large in size and has many terminals, 40 terminals, and this does not suit my projects.
PIC recommended to me the number of limbs from 18 to 20 limbs and he has a large memory that can accommodate at least 20 words.
As Ian said, put the constants in to program memory, not the sadly lacking GPR space - you should have no problem with a program as small as that one.

I don't know why Lightium suggested the 16F76, while it's a reprogrammable device it's still quite a low spec. antique, from 2002.

My current two favourite 28 pin (I think 40 pins are a bit large as well) PIC's are the 16F18857 which has 56KB of program memory, and 4KB of RAM (from 2016) - or for more 'oomph' the 18F27K42, which has 128KB of program memory, and 8KB of RAM (from 2018).
 
My friend, I want to put 15 more words in memory, but it does not fit, so I thought of adding an EEPROM because many people use this method and put a lot of other information and pictures in it.
Yeah but! you only have 192bytes of ram.. some of that needs to be your software stack. The LCD library will need a few bytes and I2C library will need some.. Thin ice my friend. Don't skate near the edges!!

What more will you be doing with this controller?
 
I still maintain that the pic16f1825 is one of the best, not new but its loaded for its day.. The pic12f1840 is my other goto small pic.
Nice, there's a bewildering array of different PIC types :D

I've not used the 16F1825, but the 12F1840 is one of my 8 pin choices, along with the 16F18313.

I think basically it makes sense to go for the newer enhanced devices, with many more peripherals and PPS.
 
My friend, I want to put 15 more words in memory, but it does not fit, so I thought of adding an EEPROM because many people use this method and put a lot of other information and pictures in it.

As Ian and I have said, stick the strings in the read only program memory as constants, only use RAM for variables.

As for EEPROM's, I used a FRAM (basically a much faster EEPROM, with no write delays) in one of our products and when I began to run out of program memory for strings (as there's a LOT of strings, many of them for debugging purposes) I moved all the string constants out to the FRAM as there was plenty of spare room there.

I read the strings out of the fram with this simple line: "char* FRAM_Str(unsigned int addr);" where addr is the address number of the string, so string 0, string 1, etc. To keep life simple, and fast, the strings are all the same size (as I've got loads of spare room in the FRAM).

So the example from the op would become something like
C:
Lcd_Out(1,6,FramStr(1));               //  "welcome"
Lcd_Out(2,1,FramStr(2));            //     "test"
:
 
As Ian said, put the constants in to program memory, not the sadly lacking GPR space - you should have no problem with a program as small as that one.

I don't know why Lightium suggested the 16F76, while it's a reprogrammable device it's still quite a low spec. antique, from 2002.

My current two favourite 28 pin (I think 40 pins are a bit large as well) PIC's are the 16F18857 which has 56KB of program memory, and 4KB of RAM (from 2016) - or for more 'oomph' the 18F27K42, which has 128KB of program memory, and 8KB of RAM (from 2018).
Thank you, my friend, for these important tips and your experiences that you give me. Indeed, I learn a lot from everyone here. I was asked about the numbers of the microcontrollers that you mentioned, and I did not find them with any electronic component seller in my country, but I found the PIC16F1509 microcontroller and I put the full code inside it, and no problem appeared. The memory is not enough, but the data does not appear on the LCD unit. I am now trying to solve this problem, and I will tell you the result.
 
Yeah but! you only have 192bytes of ram.. some of that needs to be your software stack. The LCD library will need a few bytes and I2C library will need some.. Thin ice my friend. Don't skate near the edges!!

What more will you be doing with this controller?
Thank you for this great advice, which I will always remember, and now I got another microcontroller PIC16F1509 and put the full code in it, and the problem of insufficient memory did not appear, only the data does not appear on the screen, and I am trying now to solve this problem and I will tell you the result
 
First of all. Your code shows the LCD connected to PORTB when in fact its simulated on PORTA.
Second. RA3 is an input only pin so nothing will work.
Third. I see nowhere where you disable the Analogue inputs... ANSELA and ANSELB must = 0 if you are using as digital outputs.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top