Using PIC16F628 in place of an EPROM

Status
Not open for further replies.

fjpompeo

Advanced Member level 1
Joined
Nov 29, 2003
Messages
415
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Brazil
Activity points
3,044
Hi,

How do I program a PIC16F628a to work like an eprom memory or let's say if I input this code 000100 in the input terminals RA1, RA2,... RA7 I'll give this code 10101001 in the output terminals RB1, RB2...RB8. I think this is the same like to program an eprom memory, the only care must be taken is that use a volatile memory inside the PIC to compare if the input code stays the same no change in the output so there will be changes in the output only when there is change in the input because this code will be used to program parallel a PLL that's very fast.

There will be a total of 80 combinations with 7 bit code in the inputs that must correspond to 80 combinations with 8 bit code in the output but I need only one noted combination to understand how to program input, output and logic.

Something like this:

RA1, RA2, RA3, RA4, RA5, RA6, RA7 = 7 bit world memory called input
RB1, Rb2, RB3, RB4, RB5, RB6, RB7, RB8 = 8 bit world memory called input
If input = 000100 then output = 10101001
If input = 000101 then output = 10101111

And son on....

I really will appreciate use PIC because EPROM memories are expensive, hard to find and program.

73,

Fernando - Call sign PU2PLL

https://obrazki.elektroda.pl/9571805400_1486739859.png
 

Just implement a look-up table:

1. read PORTA
2. use PORTA data as an index to a table
3. read the table
4. output it on PORTB

so there will be changes in the output only when there is change in the input
That's how all memories work but if you need to add checks to the data, do it between steps 1 and 2 above.

You need to tell us what language and assembler/compiler you are using if you want code examples.

Brian.
 

Hello.

What you have to do is really really simple. It's just a "switch" structure in the program where the conditions are that numbers, and the "output" are that different combinations. It's like a decoder, an input combination and an output one.

This is once you configured every pin (I/O), WDT, clocks and everything that "starts the engine".
---------------------------------------------------------
switch (x) //"x" is the variable, in this case, the input pins, which would be like "(PORTA & 0xFE)" (that's to "filter" the 7 last bits)
{

case 0b000100:
PORTB=0b10101001;
break;

case 0b000101:
PORTB=0b10101111;
break;


//Add every combination in the same way


}
--------------------------------

Take into account that this won't work "in parallel". It takes some time to the MCU to scan each input and put a combination at the output. If speed doesn't matter here, it will work more than fine.
 
I would do it a different way:

in C:
Code:
char values[80] = {xx, xx, xx, xx, ....and so on for all possible output values};
in = PORTA;
PORTB = values[in];

or in asm:
Code:
movf PORTA,w
call lookup
movwf PORTB

lookup:
addwf PCL,f
DT xx, xx, xx, xx, xx, xx, xx  .... and so on

It makes far smaller code and runs faster than lots of switch() statements.

Brian.
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…