Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] pic16f877a scrolling txt help

Status
Not open for further replies.

Adnan Tariq

Junior Member level 2
Joined
Dec 7, 2014
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
134
Plz ppl with great knowledge help me. i want to scroll txt but have no idea how to do so.
Following is the code an diagram.

Untitled.png

code


Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <pic.h>
 
#define DS RC1
#define SHCP RC0
#define STCP RC2
 
char a[]={0x00,0xF8, 0x14, 0x12, 0x11, 0x11, 0x12, 0x14, 0xF8,
0xFF,0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0xFF,
            0xF8, 0x14, 0x12, 0x11, 0x11, 0x12, 0x14, 0xF8,
};
 
 
 
 
 
 
void delay(unsigned int count)
{
    int i;
    unsigned int x;
    for(x=0;x<count;x++)
        for(i=0;i<525;i++);
}
void main() {
 
unsigned int j,z;
TRISC=0x00;
 
TRISD=0x00;
TRISB=0x00;
while(1)
{
 
              
               
               for (z=0;z<=24;z++)
               { 
                 PORTB=~a[z];
   
                  if(z==0)
                  {
                     DS=1;
                  }
                  else
                  {
                     DS=0;
                  }
                 
                  SHCP=1;
                  SHCP=0;
 delay(0.1);
                  STCP=1;
                  STCP=0;
 
               }

 

yes sir i read that but what should i do in coding

sir scrolling part is a bit difficult to understand in the link.
 

sorry for late reply but for scrolling a display you need to shift the column indexing by 1 position.same thing is done in the link logic. string length is the number of characters in the text.

you can try other simple way given in the below link.

https://www.edaboard.com/threads/206350/
 

Sclroll up/down:
You need to shift bits in each byte of your array and don't lost the first/last one. For shift left you should store in temporary variable the MSB bit, then apply shift operation (byte << 1) and then set the LSB bit according the MSB.
Then repeat this for all bytes in array.
Scroll left/right: simply move all bytes in array left or write and don't forget about the first/last one.
Code:
void StringMoveLeft (char * String, char Len)
{
        char tmp;
        char dat = String[0];
        char cnt;
        if (Len) tmp = Len-1;
                else tmp = StringLen(String)-1;
        for (cnt=0; cnt!=tmp; cnt++) String[cnt]=String[cnt+1];
        String[tmp]=dat;
}

void StringMoveRight (char * String, char Len)
{
        char tmp;
        char dat;
        char cnt;
        if (Len) tmp = Len-1;
                else tmp = StringLen(String)-1;
        dat = String[Len-1];
        for (cnt=tmp; cnt!=0; cnt--) String[cnt]=String[cnt-1];
        String[0]=dat;
}

PS. Schematic unreadable!!! :bang:
Who teached you to route the wires???
 
hehe sorry for the wires ok i am able to shift now i made it simple but now when i implement on hardware i burned my code to pic found rows and columns and placed wires but it wont show anything. is something wrong with my code plz check...
1.png

2.png



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
unsigned char col_a[]={1,2,4,8,16,32,64,128};
unsigned char row_a[]={0x20,0x50,0x88,0x88,0xf8,0x88,0x88,0x88};
char i,shift=4,first=1;
unsigned int j,count;
void Delay_ms(unsigned int count)
{
    int i;
    unsigned int x;
    for(x=0;x<count;x++)
        for(i=0;i<525;i++);
}
 
void main(void)
{
TRISB=0X00;
TRISC=0X00;
PORTB=0X00;
PORTC=0X00;
 
 
 
for(;;)
 
while(first==1)
{
for(i=0;i<=7;i++)
{
PORTC=~col_a[i]  ;
PORTB=row_a[i] << shift;
Delay_ms(4);
count++;
if(count==25)
{
shift--;
count=0;
if(shift==0)
{
//shift=0;
first=0;
}
}
}
}
 
while(first==0)
{
for(i=0;i<=7;i++)
{
PORTC=~col_a[i]  ;
PORTB=row_a[i] >> shift;
Delay_ms(4);
count++;
if(count==25)
{
shift++;
count=0;
if(shift==9)
{
shift=4;
first=1;
}
}
}
}
 
}
}



- - - Updated - - -

i used 4mhz crystaline oscillator and burned through micro c did i missed something..
 
Last edited by a moderator:

I didnt see the 2 22pF capacitors near the crystal.

And where is the 10K resistor on the MCLR to Vcc?

Allen
 

i was told to place crystalline oscillator directly to the pic giving 5v to mclr ,vdd and grounding vss
 

and resistors used for led are around 150 ohms
 

Did you connect the 877A as in the picture attached?

Or you have a 3-pin crystal like the one in the pix attached?

Allen
 

Attachments

  • 877a basic.PNG
    877a basic.PNG
    31 KB · Views: 131
  • 3 termin crystal images.jpg
    3 termin crystal images.jpg
    2.6 KB · Views: 147
Last edited:

The first image is the right one, I have never seen this 3 pin oscillator before
 

They are available from eBay here

**broken link removed**

and I have both 4 Mhz and 20 Mhz types. The caps are built inside like the attached pix.

Allen
 

Attachments

  • 3 termin crystal_2.png
    3 termin crystal_2.png
    8.4 KB · Views: 122
Last edited:

i m using two pin oscillator

- - - Updated - - -

allen i have not used capacitors directly attached oscillator. how much voltage should i give to mclr and vdd. didnt used 10k either.
 

two pin oscillator is good here, and give +5v to microcontroller and there's no need to use capacitor with the oscillator, instead use capacitor between +5V and GND.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top