GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIC_Microcontroller/configurations.txt at main · Harish-Patill/PIC_Microcontroller

Expand file tree

/

configurations.txt

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
125 lines (91 loc) · 5.15 KB
/

configurations.txt

Copy path

File metadata and controls

125 lines (91 loc) · 5.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
_______________________________________________________________________________________________________________________________________________
Seven segment display/7segment:
void display(char ssd[]){
for(int i=0;i<4;i++){
PORTD = ssd[i]; // Send segment pattern
PORTA = (PORTA & 0XF0)|1<<i ; // Select SSD digit
for(int dealy = 1000;dealy--;); // Small delay
}
}
_______________________________________________________________________________________________________________________________________________
trigger type: edge and level
unsigned char read_dkp(unsigned char trigger){
static unsigned char once = 1; // Retains state between function calls
if (trigger == EDGE){ // Check for edge-triggered mode
if((PORTC & 0x0F) != ALL_RELEASED && once == 1){ // Detect the key pressd
once = 0; // Prevent repeated detection
return PORTC & 0x0F; // Return the key
}
else if((PORTC & 0x0F) == ALL_RELEASED){ // Check if all keys are released
once = 1; // Enable next key detection
}
}
else if(trigger == LEVEL){ // Level-triggered mode
if((PORTC & 0x0F) != ALL_RELEASED){ // Is a key pressed?
return PORTC & 0x0F; // Return it (every call!)
}
}
return ALL_RELEASED; // No key pressed
}
==================Below LEVEL triggering has delay====================
if(trigger == LEVEL){ // Level-triggered mode
if((PORTC & 0x0F) != ALL_RELEASED){ // Is a key pressed?
// start
repeat_count++;
if(repeat_count >= 50){ // Every 50 loop iterations
repeat_count = 0;
return PORTC & 0x0F; // Return key, return it (every call!)
}
}
else{
repeat_count = 0; // Reset when released
}
// end
}
return ALL_RELEASED; // No key pressed
_______________________________________________________________________________________________________________________________________________
Timer0:
void init_timer0(void){
// Configure everything first, enable the timer last
T08BIT = 1; // 8-bit mode
T0CS = 0; // internal clock source (Fosc/4)
PSA = 1; // 1 = prescaler bypassed, 0 = prescaler used
TMR0 = 6; // preload (8-bit mode uses TMR0L actually)
// TMR0L is what claude said would be better, else it needs to read and write for both bytes.
TMR0IF = 0; // clear any old overflow flag
TMR0IE = 1; // enable Timer0 overflow interrupt
TMR0ON = 1; // start timer
}
_______________________________________________________________________________________________________________________________________________
Timer1:
void init_timer1(void){
// we can either directly assign value to T1CON or set values for each bits
// T1CON = 0x80; // 1000 0000 -> RD16=1, prescale 1:1, internal clock, timer OFF
// so for the RD16 we have 3 methods to set the value where RD16 = 1 is not one of them
// 1. use T1RD16
// 2. T1CONbits.RD16 = 1;
// 3. use the T1CON method
//T1CONbits.RD16 = 1;
T1RD16 = 1; // 16-bit read/write mode
TMR1CS = 0; // internal clock (Fosc/4)
T1CKPS1 = 0; // prescale 1:1 (T1CKPS1:T1CKPS0 = 00)
T1CKPS0 = 0; // for 1:8 set both to 1
TMR1 = 3036; // preload (65536 - 62500)
TMR1IF = 0; // clear old overflow flag
TMR1IE = 1; // enable Timer1 interrupt
TMR1ON = 1; // start timer
}
_______________________________________________________________________________________________________________________________________________
Timer2:
void init_timer2(void){
// 2 methods, either dierctly to the T2CON or to the inidvidual bits
// T2CONbits.T2OUTPS = 4; // postscale 1:5 (value = postscale - 1)
// T2CONbits.T2CKPS = 1; // prescale 1:4 (0 = 1:1, 1 = 1:4, 2 or 3 = 1:16)
T2CON = 0x21; // 0010 0001 -> postscale 1:5, prescale 1:4, timer OFF
PR2 = 249; // period register
TMR2 = 0; // preload=0
TMR2IF = 0; // timer2 interrupt flag
TMR2IE = 1; // timer2 interrupt enable
T2CONbits.TMR2ON = 1; // start the timer at last
}
_______________________________________________________________________________________________________________________________________________
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.