actor23
Member level 3
- Joined
- Dec 12, 2014
- Messages
- 56
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 515
@SunnySkyGuy, i've posted my circuit without opamp connections in other post you can see it (post #32)
if((byte & mask)==1){
SER_IN_h;
}
else if ((byte & mask)==0){
SER_IN_l;
}
if(byte & mask){
SER_IN_h;
}
else {
SER_IN_l;
}
if(byte & mask){
SER_IN_h;
}
else {
SER_IN_l;
}
Just legal C...Compiler gives error when trying to this.
void sendByte(unsigned char byte) {
char i = 0;
for(i = 0; i < 8; i++) {
if(byte & 0x80)
SER_IN_h;
else
SER_IN_l;
SRCK_h;
_delay_cycles(50-1);
SRCK_l;
byte <<= 1;
}
RCK_h;
_delay_cycles(50-1);
RCK_l;
}
#include "msp.h"
#include "main.h"
//#include "stdint.h"
char capture[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
char select = 0;
unsigned int number = 12345;
char display[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
char *ptr2char = 0;
void sendByte(unsigned char byte);
int main(void) {
WDTCTL = WDTPW | WDTHOLD;
// Configure GPIO
P5DIR |= BIT4 | BIT5; // CLK ve RST çıkışları
P4DIR |= BIT7 | BIT5 | BIT4; //SER_IN, RCK,SRCK
P5OUT &= ~BIT5;
P5OUT &= ~BIT4;
P4OUT &= ~BIT7;
P4OUT &= ~BIT5;
P4OUT &= ~BIT4;
RST_h;
_delay_cycles(50-1);
RST_l;
TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 5000; // 5ms de bir interrupt
TA0CTL = TASSEL__SMCLK | MC__UP ; // SMCLK, continuous mode
ptr2char = &display[0];
SCB_SCR |= SCB_SCR_SLEEPONEXIT; // Enable sleep on exit from ISR
__enable_interrupt();
NVIC_ISER0 = 1 << ((INT_TA0_0 - 16) & 31);
while (1)
{
display[0] = 0x06;
display[1] = 0x5B;
display[2] = 0x4F;
display[3] = 0x66;
display[4] = 0x6D;
}
}
// Timer A0 interrupt service routine
void TimerA0_0IsrHandler(void) {
switch(select) {
case 0:
case 2:
case 4:
case 6:
case 8:
sendByte(*ptr2char++);
break;
case 1:
case 3:
case 5:
case 7:
case 9:
sendByte(0x00);
break;
};
++select;
if((select == 0) || (select == 1) || (select == 3) || (select == 5) || (select == 7) || (select == 9)) {
CLK_h;
_delay_cycles(20-1);
CLK_l;
}
if(select == 10) {
RST_h;
_delay_cycles(20-1);
RST_l;
select = 0;
ptr2char = &display[0];
}
TA0CCTL0 &= ~CCIFG;
}
void sendByte(unsigned char byte) {
char i = 0, mask = 0x80;
for(i = 0; i < 8; i++) {
if(byte & mask){
SER_IN_h;
}
else {
SER_IN_l;
}
SRCK_h;
_delay_cycles(5-1);
SRCK_l;
mask >>= 1;
}
RCK_h;
_delay_cycles(5-1);
RCK_l;
}
++select;
if((select == 0) || (select == 1) || (select == 3) || (select == 5) || (select == 7) || (select == 9)) {
CLK_h;
_delay_cycles(20-1);
CLK_l;
}
if((select == 0) || (select == 1) || (select == 3) || (select == 5) || (select == 7) || (select == 9)) {
CLK_h;
_delay_cycles(20-1);
CLK_l;
}
++select;
for all digits
{
disable all digits
output next digit code
enable next digit
delay
}
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 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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 char mask[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90}; char select = 0, myFlags = 0; unsigned int number = 12345; char display[5] = {0, 0, 0, 0, 0}; char setCounter = 0; unsigned int delayCounter = 0; sbit blinkDisplay at myFlags.B0; sbit SH_CP at LATC0_bit; sbit DS at LATC1_bit; sbit ST_CP at LATC2_bit; sbit CD4017_CLK at LATC3_bit; sbit CD4017_RST at LATC4_bit; //Timer1 //Prescaler 1:1; TMR1 Preload = 63536; Actual Interrupt Time : 2 ms //Place/Copy this part in declaration section void InitTimer1() { T1CON = 0x01; TMR1IF_bit = 0; TMR1H = 0xF8; TMR1L = 0x30; TMR1IE_bit = 1; INTCON = 0xC0; } void sendByte(unsigned char byte) { char i = 0, mask = 0x80; for(i = 0; i < 8; i++) { if(byte & mask) DS = 1; else DS = 0; SH_CP = 1; Delay_us(50); SH_CP = 0; mask >>= 1; } ST_CP = 1; Delay_us(50); ST_CP = 0; } void Interrupt() { if(TMR1IF_bit) { //Enter your code here switch(select) { case 0: if(setCounter == 1) { if(blinkDisplay == 1)sendByte(display[0]); else if(blinkDisplay == 0)sendByte(0xFF); } else sendByte(display[0]); break; case 2: if(setCounter == 2) { if(blinkDisplay == 1)sendByte(display[1]); //else if(blinkDisplay == 0)sendByte(0xFF); } else sendByte(display[1]); break; case 4: if(setCounter == 3) { if(blinkDisplay == 1)sendByte(display[2]); //else if(blinkDisplay == 0)sendByte(0xFF); } else sendByte(display[2]); break; case 6: if(setCounter == 4) { if(blinkDisplay == 1)sendByte(display[3]); //else if(blinkDisplay == 0)sendByte(0xFF); } else sendByte(display[3]); break; case 8: if(setCounter == 5) { if(blinkDisplay == 1)sendByte(display[4]); //else if(blinkDisplay == 0)sendByte(0xFF); } else sendByte(display[4]); break; case 1: case 3: case 5: case 7: case 9: sendByte(0xFF); break; }; ++select; if((select == 0) || (select == 1) || (select == 3) || (select == 5) || (select == 7) || (select == 9)) { CD4017_CLK = 1; Delay_us(200); CD4017_CLK = 0; } if(select == 10) { CD4017_RST = 1; Delay_us(200); CD4017_RST = 0; select = 0; } TMR1H = 0xF8; TMR1L = 0x30; if(++delayCounter == 250) { delayCounter = 0; blinkDisplay = ~blinkDisplay; } TMR1IF_bit = 0; } } void main() { CM1CON0 = 0x00; CM2CON0 = 0x00; SLRCON = 0x00; ANSELA = 0x00; ANSELB = 0x00; ANSELC = 0x00; TRISA = 0xC0; TRISB = 0x01; TRISC = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; LATA = 0x00; LATB = 0x00; LATC = 0x00; InitTimer1(); while(1) { display[0] = mask[number / 10000]; display[1] = mask[(number / 1000) % 10]; display[2] = mask[(number / 100) % 10]; display[3] = mask[(number / 10) % 10]; display[4] = mask[number % 10]; if(!RB0_bit) { Delay_ms(50); while(!RB0_bit); if(++setCounter == 6)setCounter = 0; if(setCounter) { blinkDisplay = 1; delayCounter = 0; } else { blinkDisplay = 0; } } } }
Your photo shows crosstalk of the next digit code, which happens due to a unsuitable switching sequence. In a brief, the sequence should be:
Code:for all digits { disable all digits output next digit code enable next digit delay }
The actual circuit have 2 TLC274
Counter is TC4017 but in the picture i drawn it CD4017 it is not problem
Connection is correct i tested.
TLC274 power is +5.7V and TC4017 and TPIC5b's are +5V(because if i supply TLC274 with +5V outputs are approx. 4.3V)
I've tested TC4017 outputs while RST=0 give CLK=1 and 0 and again and again, none of the outputs of the IC goes high. Every measurement shows 0.01V or 0.05V max :S
I will try different IC :S for example CD4017 same but different manufacturer.
- - - Updated - - -
I've solved the 4017 problem by replacing TC4017 with CD4017BE. TC4017 does not work properly idk. Now,new problem is that while i am giving 0x00 off each display, segment A is always on also(for each digit), i can realize the mux operation my own eyes even the interrupt time 2ms or below(by assigning lower values to timer base i.e not 5000 instead 1000 or 500).
Please examine my last code and give me advice.
Thanks in advance.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?