Nicely done. I enjoy learning your method of constructing the C program. Do make more videos like this, it's very helpful and interesting to watch. Could you make some video involving PWM with the PIC in the near future? For example taking an analogue input voltage and converting it to a a PWM output. Thanks
Dear Hoffman I would to thank you so much for the great TH-cam tutorials on PIC programming. I have been watching one of your tutorial [Using PIC Interrupt to drive LED display] and was so amazed by the way you handled the programming of 7 segment display. I would greatly appreciate it, if I get hold of the source code.I just need it to further my knowledge in PIC programming. could you please post it somewhere i.e. on your youtube channel. Thanks very much in advance Best Regards Tamimi
That was right on. I am experimenting with interrupts also for the 8051 using MCU-8051 IDE... I wondered what compiler you are using for the PIC ??? it is not MPLAB. Thank you.
Thank you for posting a great video which shows how timer/interrupt can be used for updating LED 7 segment display. I have a question... I don't see in your code something like TMR0ON or TMR0EN to enable Timer 0. In this particular PIC, if TMR0CS is set to use internal oscillator, is that automatically enable timer 0?
You don't specifically turn TMR0 on or off in the PIC16F88x family, so I guess in that sense it's always on. However, TMR0 won't increment until it's supplied with a clock source. So no clock would equate to the timer being off. So, yes, it's already on and all you need to do is configure TMR0 to operate the way you want. This statement only applies to TMR0 in the PIC16F88x family and other timers and other families will have different configuration settings, check the datasheet for timer configuration specifics.
"Thank You", thank you very much. That was very good, and informative. How and where can I find basic and beginning tutorials on PIC assembly language programming? Let me know 😎😃😂😎
You're welcome, glad the video was of help. There are a couple books you might want to check out "123 PIC Microcontroller projects for the Evil Genius" and "Programming and Customizing PICmicro Microcontrollers". You can get them both off Amazon.
It seems very simple but when I tried to do mine the digits became all messed up. I tried to look in the web the reason since when I simulated in ISIS proteus with went all good and it's problably due to MRW and i tried to fix it but no success. I am using a PIC16F628A with 4 MHZ external clock source and interrupting the timer0 as you in order to do a timer for a 7seg 4 digit display in common anode config. Is it possible for u to approach this kind of error in MCU's ? thanks in advance. Btw the link for more data on my issue with the project .
Hello Goncola, I looked over your code and have the following suggestions: 1) When you enter the interrupt service routine use the command GIE = 0 and before you leave use the command GIE = 1. This turns off global interrupts and prevents a interrupt service call from happening while you are servicing the current interrupt. Not usually a problem when you only have 1 interrupt, but can cause issues when you have multiple interrupts. 2) I think the "if else" statements in the interrupt service routine might be the source of the problem. Try removing the "if else" statements and just straight "if" and at the end of the service routine increment "control" and test for it being over 4. So something like this: GIE = 0; // Turn off global interrupts so we aren't interrupted during interrupt service routine. if(control==1) { ...code here... } if(control==2) { ...code here... } if(control==3) { ...code here... } if(control==4) { ...code here... } if(++control > 4) control = 1; GIE = 1; // Turn global interrupts back on.
Hey David Thanks for taking time to see my code and advise me! I tried doing what u said but no success again, I really think it's because that RMW problem because my code works in simulation. I have to try using a "shadow register" when assigning the ports(I reed about it on Microchip website ahaha). Not sure how to do it yet tough, do you have any experience applying this method ? Thanks in advance
Possibly, but I don't think so. You're not running the MCU super fast and from what I saw in the code you're not writing to a port register and then reading right back from it (which can cause issues). What I'll do in a situation like this is to comment out as much code as possible to get to bare bones operation. You could comment out all the code that updates the digits and just leave one operational, this can help track down wiring errors. And as each segment of code is confirmed as working correctly, slowly add the others back in. Another trick is to slow down the refresh rate of the display so you can actually see each digit turn on and off, this will help determine exactly what the circuit is really doing.
Thanks for those advices I used max prescaler and watched the digits changing, only the first one is doing what it should the other have "garbage"...and have the same code cant really understand how's that possible... gonna try commenting step by step like u said
I found the error, it was just a bad initialization because apperantly u cant declare and assign several variables in the same line.... jesus.... 1 week on this... thanks for the help David ur advises were gold on solving this problem. Looking forward for more videos on C for PIC, I am now using MikroC with IPE of MPLAB X to download the firmware trough PICKIT3 but I will try to follow ur videos anyway. All the best
Hallo Mr.Hoffman , I'm useing MPLAB X XC8 C compiler . Im learning at the moment programing pic microcontrollers . I do it in my free time , I already learned a lot , but I got a lot of question to understand things about c programing, I alsow use google.com but its not the same like if sombody explain .so I would like to learn pic programing in c in a profesional level.I ask for a help from u , if u want to explain some stuff to me? i wolud be appreciate and fully thankfull.maby we can take a contact over Skype , or what ever u using. thx in advance. cincerly Jozsef Furo
Nicely done. I enjoy learning your method of constructing the C program. Do make more videos like this, it's very helpful and interesting to watch.
Could you make some video involving PWM with the PIC in the near future? For example taking an analogue input voltage and converting it to a a PWM output. Thanks
Dear Hoffman
I would to thank you so much for the great TH-cam tutorials on PIC programming. I have been watching one of your tutorial [Using PIC Interrupt to drive LED display] and was so amazed by the way you handled the programming of 7 segment display. I would greatly appreciate it, if I get hold of the source code.I just need it to further my knowledge in PIC programming. could you please post it somewhere i.e. on your youtube channel.
Thanks very much in advance
Best Regards
Tamimi
Do you can make zoom in the screen?
That was right on. I am experimenting with interrupts also for the 8051 using MCU-8051 IDE... I wondered what compiler you are using for the PIC ??? it is not MPLAB. Thank you.
+ljay0778 I'm using MPLAB X and XC8 (Microchip's C compiler) in free mode.
Thanks David for the clarification!
Thank you for posting a great video which shows how timer/interrupt can be used for updating LED 7 segment display.
I have a question... I don't see in your code something like TMR0ON or TMR0EN to enable Timer 0. In this particular PIC, if TMR0CS is set to use internal oscillator, is that automatically enable timer 0?
You don't specifically turn TMR0 on or off in the PIC16F88x family, so I guess in that sense it's always on. However, TMR0 won't increment until it's supplied with a clock source. So no clock would equate to the timer being off. So, yes, it's already on and all you need to do is configure TMR0 to operate the way you want.
This statement only applies to TMR0 in the PIC16F88x family and other timers and other families will have different configuration settings, check the datasheet for timer configuration specifics.
Thank you David !
You're welcome :)
"Thank You", thank you very much. That was very good, and informative. How and where can I find basic and beginning tutorials on PIC assembly language programming? Let me know 😎😃😂😎
You're welcome, glad the video was of help. There are a couple books you might want to check out "123 PIC Microcontroller projects for the Evil Genius" and "Programming and Customizing PICmicro Microcontrollers". You can get them both off Amazon.
Again, "Thank You", thank you very much...
Nice video quality! you should make more videos! :)
Thanks very much for the tutorial......could you please post the source code......
How to display ADC value on this seven segment displays
I have problem i want contact you Mr Hoffman
It seems very simple but when I tried to do mine the digits became all messed up. I tried to look in the web the reason since when I simulated in ISIS proteus with went all good and it's problably due to MRW and i tried to fix it but no success.
I am using a PIC16F628A with 4 MHZ external clock source and interrupting the timer0 as you in order to do a timer for a 7seg 4 digit display in common anode config.
Is it possible for u to approach this kind of error in MCU's ? thanks in advance. Btw the link for more data on my issue with the project .
Hello Goncola,
I looked over your code and have the following suggestions:
1) When you enter the interrupt service routine use the command GIE = 0 and before you leave use the command GIE = 1. This turns off global interrupts and prevents a interrupt service call from happening while you are servicing the current interrupt. Not usually a problem when you only have 1 interrupt, but can cause issues when you have multiple interrupts.
2) I think the "if else" statements in the interrupt service routine might be the source of the problem. Try removing the "if else" statements and just straight "if" and at the end of the service routine increment "control" and test for it being over 4. So something like this:
GIE = 0; // Turn off global interrupts so we aren't interrupted during interrupt service routine.
if(control==1)
{
...code here...
}
if(control==2)
{
...code here...
}
if(control==3)
{
...code here...
}
if(control==4)
{
...code here...
}
if(++control > 4) control = 1;
GIE = 1; // Turn global interrupts back on.
Hey David
Thanks for taking time to see my code and advise me!
I tried doing what u said but no success again, I really think it's because that RMW problem because my code works in simulation. I have to try using a "shadow register" when assigning the ports(I reed about it on Microchip website ahaha). Not sure how to do it yet tough, do you have any experience applying this method ? Thanks in advance
Possibly, but I don't think so. You're not running the MCU super fast and from what I saw in the code you're not writing to a port register and then reading right back from it (which can cause issues).
What I'll do in a situation like this is to comment out as much code as possible to get to bare bones operation. You could comment out all the code that updates the digits and just leave one operational, this can help track down wiring errors. And as each segment of code is confirmed as working correctly, slowly add the others back in.
Another trick is to slow down the refresh rate of the display so you can actually see each digit turn on and off, this will help determine exactly what the circuit is really doing.
Thanks for those advices I used max prescaler and watched the digits changing, only the first one is doing what it should the other have "garbage"...and have the same code cant really understand how's that possible... gonna try commenting step by step like u said
I found the error, it was just a bad initialization because apperantly u cant declare and assign several variables in the same line.... jesus.... 1 week on this... thanks for the help David ur advises were gold on solving this problem. Looking forward for more videos on C for PIC, I am now using MikroC with IPE of MPLAB X to download the firmware trough PICKIT3 but I will try to follow ur videos anyway. All the best
pls write the code in assembly
can u pls write the code in assemble
Hallo Mr.Hoffman , I'm useing MPLAB X XC8 C compiler . Im learning at the moment programing pic microcontrollers .
I do it in my free time , I already learned a lot , but I got a lot of question to understand things about c programing, I alsow use google.com but its not the same like if sombody explain .so I would like to learn pic programing in c in a profesional level.I ask for a help from u , if u want to explain some stuff to me? i wolud be appreciate and fully thankfull.maby we can take a contact over Skype , or what ever u using. thx in advance. cincerly Jozsef Furo
+Fu Ro Hello Jozsef, right now I've pretty busy but if you have specific questions feel free to send them to me and I'll answer what I can.