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.

How to use Interrupt in PIC16F877A in C..??

Status
Not open for further replies.
I really can't comment on hardware until I build one myself..... I will try to build your circuit in ISIS later.

As to the displaying.... You need a buffer... If you place your first character in to the buffer The interrupt cycles through the columns of the buffer one by one.

As the interrupt works on the buffer only ( I used two Leds[8] and leds2[8] ) This was for scrolling!!! The original Idea was Nigel's As I did it for his hardware.

You might want to read through Nigel's ASM routine as well.. Tutorial 13...
 
Code:
((ASCII CODE - 0x20) * 7 ) As each char is 7 bits long...
what is the use of *7 here???? i am getting it

In your tutorial you are using character how, can't i use them without any hex value conversion fro array???

Code:
display("Hello world!!");		// display a message
		clear();						// start again
		DelayMs(1000);
		}
 
All your characters are 7 bytes so they are to the power of 7..... 0, 7, 14, 21, 28, 35 etc... ( this is for a 1 d array )...

Look at the display() routine each character is placed in the buffer leds[].... The interrupt takes care of blitting to the port once the first character is done and shifted using the second buffer leds2[] the next character is written.

The interrupt is blitting the character to the matrix very fast., so you don't need to worry about the rows and columns as its being done automatically.
 
All your characters are 7 bytes so they are to the power of 7..... 0, 7, 14, 21, 28, 35 etc... ( this is for a 1 d array )...

Yes they are but what does *7 it will do??

OK, i think you are trying say that all 49bytes is to be loaded, right??
If yes then how to load or make a buffer for it:??
 
Oh I see... You are talking about buffering.... The ASCII comment was for storage only...

Right.... First access the character from your 2 d array.... place it in the 8x8 buffer ( I called mine leds[])... If you have your interrupt configured correctly.. It will display the character...

Code:
unsigned char leds[8];

for(x=0;x<8,x++)
   leds[x] = font1[character][x];
 
What doubts are you having..

You have to remember that as I have done this already, I think it's relatively easy..

I'm not the best at "showing" how to do things.... I really need to video me doing the job so you can see how it works...
 
Hi ,

I have just completed the 10x24 LED display with 74164 shift register connect to column the PORTB is driving rows.
I have tested it with my old code it is working fine i found one problem that the text in continuous way... as it comes.
i am not getting how to load all the text and shift it...
 
I take it were using column drivers.... The sample in my tutorial uses column driving... you need to load your buffer first... How many digits are on display at any one time.

I have not make buffer yet don't know how to do this( please tel steps how to do/ make the scrolling effect)..
till now i have done nothing with scrolling digit as i have shown you my cost in past post they only move one digit in whole 10x28 led matrix...
 
Yes I will show you.... HOW MANY CHARACTERS ARE ON SHOW AT ANY ONE TIME... the reason I ask is you characters ( in the 2d array) are 7x8.... how does this correspond to you led matrix of 10x28. Are the top two leds going to be off? Is there 4 characters in all? If there are 4 characters on at a time you need to buffer 4 characters buffer[4][7]; Then use the buffer in the interrupt and update the contents outside of the interrupt.

Code:
void interrupt ISR()
   {
   if(TMR2IF)
      {
       if(pos == 0)
             DATA = 1;     // start column
       rows = 0;           // turn off current row
       CLK = 1;             //  shift to next column
       CLK = 0;
       rows = buffer[pos];   // retrieve buffer data
       DATA = 0;       // no more data ( this will shift through all the columns)
       if(pos++ == 28) pos = 0;     // back to first column
       TMR2IF = 0;    // clear interrupt flag
       }
   }


Then you fill the buffer with the current data...
 
Are the top two leds going to be off?

yes, as per the font. if i need other font how to get it??

If there are 4 characters on at a time you need to buffer 4 characters buffer[4][7]
can you give me more hint with algorithm, as my code are scrolling with single character after completing one round the new character is coming..
 
Tell me Ritesh.... When I watch the progress on AAC... Are we talking about the same "Animation", The reason I ask is.. You may be getting the wrong info from a couple of users... They are talking about graphical screens.


Here's he flow!! flow.PNG


The display routine takes the characters one by one.. Line by line, and fills the buffer... The buffer is a linear portion of memory (Ram) that is the same size as the led display... The interrupt selects the columns and then blits the relevant data from the buffer to the screen..
 
In your video, you have successfully done the scrolling...

I don't understand your problem... If the concept of the task is too hard... start with something simpler... If you can "grasp" the concept of tutorial 13's way of scrolling a single character, then your understanding will help with the other 4 characters.
 
In your video, you have successfully done the scrolling...

I don't understand your problem...
The problem is that single text is scrolling when i am saving font with char 8bit
when I am using int i.e.16bit i save the font like this then 0x040a

I have seen your tutorial but not getting properly what you are doing!
 
Hi again,

so, I have to do this?

char/int LED_buffer[10][28]={place text/ character here };

one thing more how to make control switch for bi color LED Display both anode are connected to 74164 and cathode to be connected with PORT B via bc547 i want to change color from software so, bit 7 of PORT D will be used?
 
No!!! take a look at my font

Code:
const unsigned char fnt[]= {
0b00000000,		// SPACE
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,

0b00000000,		// !
0b00010000,
0b00000000,
0b00000000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,

0b00000000,		// "
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00101000,
0b00101000,
0b00101000,

0b00000000,		// #
0b00101000,
0b00101000,
0b01111100,
0b00101000,
0b01111100,
0b00101000,
0b00101000,

0b00000000,		// $
0b00010000,
0b01111000,
0b00010100,
0b00111000,
0b01010000,
0b00111100,
0b00010000,

0b00000000,		// %
0b00001100,
0b01001100,
0b00100000,
0b00010000,
0b00001000,
0b01100100,
0b01100000,

0b00000000,		// &
0b00110100,
0b01001000,
0b01010100,
0b00100000,
0b01010000,
0b01001000,
0b00110000,

0b00000000,		// ,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00100000,
0b00010000,
0b00110000,

0b00000000,		// (
0b00001000,
0b00010000,
0b00100000,
0b00100000,
0b00100000,
0b00010000,
0b00001000,

0b00000000,		// )
0b00100000,
0b00010000,
0b00001000,
0b00001000,
0b00001000,
0b00010000,
0b00100000,

0b00000000,		// *
0b00010000,
0b01010100,
0b00111000,
0b01010100,
0b00010000,
0b00000000,
0b00000000,

0b00000000,		// +
0b00000000,
0b00010000,
0b00010000,
0b01111100,
0b00010000,
0b00010000,
0b00000000,

0b00000000,		// ,
0b00100000,
0b00010000,
0b00110000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,

0b00000000,		// -
0b00000000,
0b00000000,
0b00000000,
0b01111100,
0b00000000,
0b00000000,
0b00000000,

0b00000000,		// .
0b00110000,
0b00110000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,

0b00000000,		// /
0b00000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000000,

0x00,			// 0
0x38,
0x44,
0x4C,
0x54,
0x64,
0x44,
0x38,

0x00,			// 1
0x38,
0x10,
0x10,
0x10,
0x10,
0x30,
0x10,

0x00,			// 2
0x7C,
0x20,
0x10,
0x08,
0x04,
0x44,
0x38,

0x00,			// 3
0x38,
0x44,
0x04,
0x08,
0x10,
0x08,
0x7C,

0x00,			// 4
0x08,
0x08,
0x7C,
0x48,
0x28,
0x18,
0x08,

0x00,			// 5
0x38,
0x44,
0x04,
0x04,
0x78,
0x40,
0x7C,

0x00,			// 6
0x38,
0x44,
0x44,
0x78,
0x40,
0x20,
0x18,

0x00,			// 7
0x20,
0x20,
0x20,
0x10,
0x08,
0x04,
0x7C,

0x00,			// 8
0x38,
0x44,
0x44,
0x38,
0x44,
0x44,
0x38,

0x00,			// 9
0x30,
0x08,
0x04,
0x3C,
0x44,
0x44,
0x38,

0b00000000,		// :
0b00000000,
0b00110000,
0b00110000,
0b00000000,
0b00110000,
0b00110000,
0b00000000,


0b00000000,		// /
0b00100000,
0b00010000,
0b00110000,
0b00000000,
0b00110000,
0b00110000,
0b00000000,

0b00000000,		// <
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,

0b00000000,		// =
0b00000000,
0b00000000,
0b01111100,
0b00000000,
0b01111100,
0b00000000,
0b00000000,

0b00000000,		// >
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00010000,
0b00100000,
0b01000000,

0b00000000,		// ?
0b00010000,
0b00000000,
0b00010000,
0b00001000,
0b00000100,
0b01000100,
0b00111000,


0b00000000,		// @
0b00111000,
0b01010100,
0b01010100,
0b00110100,
0b00000100,
0b01000100,
0b00111000,

0b00000000,		// A
0b01000100,
0b01000100,
0b01111100,
0b01000100,
0b01000100,
0b01000100,
0b00111000,

0b00000000,		// B
0b01111000,
0b01000100,
0b01000100,
0b01111000,
0b01000100,
0b01000100,
0b01111000,

0b00000000,		// C
0b00111000,
0b01000100,
0b01000000,
0b01000000,
0b01000000,
0b01000100,
0b00111000,

0b00000000,		// D
0b01110000,
0b01001000,
0b01000100,
0b01000100,
0b01000100,
0b01001000,
0b01110000,

0b00000000,		// E
0b01111100,
0b01000000,
0b01000000,
0b01111000,
0b01000000,
0b01000000,
0b01111100,

0b00000000,		// F
0b01000000,
0b01000000,
0b01000000,
0b01111000,
0b01000000,
0b01000000,
0b01111100,

0b00000000,		// G
0b00111100,
0b01000100,
0b01000100,
0b01011100,
0b01000000,
0b01000100,
0b00111000,

0b00000000,		// H
0b01000100,
0b01000100,
0b01000100,
0b01111100,
0b01000100,
0b01000100,
0b01000100,

0b00000000,		// I
0b00111000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00111000,

0b00000000,		// J
0b00110000,
0b01001000,
0b00001000,
0b00001000,
0b00001000,
0b00001000,
0b00011100,

0b00000000,		// K
0b01000100,
0b01001000,
0b01010000,
0b01100000,
0b01010000,
0b01001000,
0b01000100,

0b00000000,		// L
0b01111100,
0b01000000,
0b01000000,
0b01000000,
0b01000000,
0b01000000,
0b01000000,

0b00000000,		// M
0b01000100,
0b01000100,
0b01000100,
0b01010100,
0b01010100,
0b01101100,
0b01000100,

0b00000000,		// N
0b01000100,
0b01000100,
0b01001100,
0b01010100,
0b01100100,
0b01000100,
0b01000100,

0b00000000,		// O
0b00111000,
0b01000100,
0b01000100,
0b01000100,
0b01000100,
0b01000100,
0b00111000,

0b00000000,		// P
0b01000000,
0b01000000,
0b01000000,
0b01111000,
0b01000100,
0b01000100,
0b01111000,

0b00000000,		// Q
0b00110100,
0b01001000,
0b01010100,
0b01000100,
0b01000100,
0b01000100,
0b00111000,

0b00000000,		// R
0b01000100,
0b01001000,
0b01010000,
0b01111000,
0b01000100,
0b01000100,
0b00111000,

0b00000000,		// S
0b01111000,
0b00000100,
0b00000100,
0b00111000,
0b01000000,
0b01000000,
0b00111100,

0b00000000,		// T
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b01111100,

0b00000000,		// U
0b00111000,
0b01000100,
0b01000100,
0b01000100,
0b01000100,
0b01000100,
0b01000100,

0b00000000,		// V
0b00010000,
0b00101000,
0b01000100,
0b01000100,
0b01000100,
0b01000100,
0b01000100,

0b00000000,		// W
0b00101000,
0b01010100,
0b01010100,
0b01000100,
0b01000100,
0b01000100,
0b01000100,

0b00000000,		// X
0b01000100,
0b01000100,
0b00101000,
0b00010000,
0b00101000,
0b01000100,
0b01000100,

0b00000000,		// Y
0b00010000,
0b00010000,
0b00010000,
0b00101000,
0b01000100,
0b01000100,
0b01000100,

0b00000000,		// Z
0b01111100,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b01111100,

0b00000000,		// [
0b00111000,
0b00100000,
0b00100000,
0b00100000,
0b00100000,
0b00100000,
0b00111000,

0b00000000,		// ???
0b00010000,
0b00010000,
0b01111100,
0b00010000,
0b01111100,
0b00101000,
0b01000100,

0b00000000,		// ]
0b00111000,
0b00001000,
0b00001000,
0b00001000,
0b00001000,
0b00001000,
0b00111000,

0b00000000,		// ^
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01000100,
0b00101000,
0b00010000,

0b00000000,		// _
0b01111100,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,

0b00000000,		// `
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00001000,
0b00010000,
0b00100000,

0b00000000,		// a
0b00111100,
0b01000100,
0b00111100,
0b00000100,
0b00111000,
0b00000000,
0b00000000,

0b00000000,		// b
0b01111000,
0b01000100,
0b01000100,
0b01100100,
0b01011000,
0b01000000,
0b01000000,

0b00000000,		// c
0b00111000,
0b01000100,
0b01000000,
0b01000000,
0b00111000,
0b00000000,
0b00000000,

0b00000000,		// d
0b00111100,
0b01000100,
0b01000100,
0b01001100,
0b00110100,
0b00000100,
0b00000100,

0b00000000,		// e
0b00111000,
0b01000000,
0b01111100,
0b01000100,
0b00111000,
0b00000000,
0b00000000,

0b00000000,		// f
0b00100000,
0b00100000,
0b00100000,
0b01110000,
0b00100000,
0b00100100,
0b00011000,

0b00111000,		// g
0b00000100,
0b00000100,
0b00111100,
0b01000100,
0b01000100,
0b00111100,
0b00000000,

0b00000000,		// h
0b01000100,
0b01000100,
0b01000100,
0b01100100,
0b01011000,
0b01000000,
0b01000000,

0b00000000,		// i
0b00111000,
0b00010000,
0b00010000,
0b00010000,
0b00110000,
0b00000000,
0b00010000,

0b00110000,		// j
0b01001000,
0b00001000,
0b00001000,
0b00001000,
0b00011000,
0b00000000,
0b00001000,

0b00000000,		// k
0b01001000,
0b01010000,
0b01100000,
0b01010000,
0b01001000,
0b01000000,
0b01000000,

0b00000000,		// l
0b00111000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00110000,

0b00000000,		// m
0b01010100,
0b01010100,
0b01010100,
0b01010100,
0b01111000,
0b00000000,
0b00000000,

0b00000000,		// n
0b01000100,
0b01000100,
0b01000100,
0b01100100,
0b01011000,
0b00000000,
0b00000000,

0b00000000,		// o
0b00111000,
0b01000100,
0b01000100,
0b01000100,
0b00111000,
0b00000000,
0b00000000,

0b01000000,		// p
0b01000000,
0b01000000,
0b01111000,
0b01000100,
0b01111000,
0b00000000,
0b00000000,

0b00000100,		// q
0b00000100,
0b00000100,
0b00111100,
0b01001100,
0b00110100,
0b00000000,
0b00000000,

0b00000000,		// r
0b01000000,
0b01000000,
0b01000000,
0b01100100,
0b01011000,
0b00000000,
0b00000000,

0b00000000,		// s
0b01111000,
0b00000100,
0b00111000,
0b01000000,
0b00111000,
0b00000000,
0b00000000,

0b00000000,		// t
0b00011000,
0b00100100,
0b00100000,
0b00100000,
0b01110000,
0b00100000,
0b00100000,

0b00000000,		// u
0b00110100,
0b01001100,
0b01000100,
0b01000100,
0b01000100,
0b00000000,
0b00000000,

0b00000000,		// v
0b00010000,
0b00101000,
0b01000100,
0b01000100,
0b01000100,
0b00000000,
0b00000000,

0b00000000,		// w
0b00101000,
0b01010100,
0b01010100,
0b01000100,
0b01000100,
0b00000000,
0b00000000,

0b00000000,		// x
0b01000100,
0b00101000,
0b00010000,
0b00101000,
0b01000100,
0b00000000,
0b00000000,

0b00111000,		// y
0b00000100,
0b00000100,
0b00111100,
0b01000100,
0b01000100,
0b00000000,
0b00000000,

0b00000000,		// Z
0b01111100,
0b00100000,
0b00010000,
0b00001000,
0b01111100,
0b00000000,
0b00000000,

0b00000000,		// (
0b00001000,
0b00010000,
0b00010000,
0b00100000,
0b00010000,
0b00010000,
0b00001000,

0b00000000,		// |
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,

0b00000000,		// )
0b00100000,
0b00010000,
0b00010000,
0b00001000,
0b00010000,
0b00010000,
0b00100000,
0b00000000,

0b00000000,		// right arrow
0b00000000,
0b00010000,
0b00001000,
0b01111100,
0b00001000,
0b00010000,
0b00000000,

0b00000000,		// left arrow
0b00000000,
0b00010000,
0b00100000,
0b01111100,
0b00100000,
0b00010000,
0b00000000};

Line by line.... This makes it MUCH easier to manipulate... Each character is 8 bytes long... If you create a buffer
Code:
char buffer[28];

You can fill the buffer line by line.... Lets start with 'A' hex 0x41..... We put our font pointer to 0x41 - 0x20 ( we started our characters at 0x20 ' ' ( space ) then we multiply by the size of the character (8) to find out the place we need to be...

Then line by line we take each row of data from the font and place it in the buffer... Then do it for the next row then so on until the character is in the buffer. buffer[0] to buffer[7] will now be an exact copy of font[264] to font[270] ( the location of the bitmap 'A' )


Then repeat for the next 3 characters.... Once the buffer is full ( shifted or whatever ) the interrupt takes buffer[0] though buffer[28] and lights the LED columns one by one..

To rotate left just start the characters at buffer[1] then buffer[2]... To rotate right just loose the first column, then the first and second,etc...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top