with flowchart below there is communication between this chip and two different eeproms, with the code how its written the chip select for chip#1 which is pin C0 doesn't work! you can move this to any output pin on the micro as long as its not on PORTC and it will work
i did a bunch of testing and came with the conclusion that tmr1 interrupt enable is causing the issue, if i disable tmr1 interrupt enable or convert it into a tmr4 interrupt the problem is gone and i have control of the c0 pin again
things like this bug me as i don't understand whats going on, can someone expain technically what is happening
pin c0 inop confusion
Moderator: Benj
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: pin c0 inop confusion
Hi Brandon.
C0 is not only Digital I/O but its also Timer1 osc input/output.
What I believe is happening is when timer1 is enabled, then internally to the microcontroller C0 has been reassigned from Digital I/O to Timer1 osc I/O
Since timer interrupt is set for internal clock, then C0 is disabled?
I will see if I can look further into this.
Martin
C0 is not only Digital I/O but its also Timer1 osc input/output.
What I believe is happening is when timer1 is enabled, then internally to the microcontroller C0 has been reassigned from Digital I/O to Timer1 osc I/O
Since timer interrupt is set for internal clock, then C0 is disabled?
I will see if I can look further into this.
Martin
Martin
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: pin c0 inop confusion
hey martin, its not only c0, i also tried it on c1 and it did the same thing, the c2 input did work through out the whole process which is the cs for the second eeprom chip.... i converted flowchart to TMR4, changed a couple things in the flowchart that i screwed up on (noticed with logic16 )and it works as expected, generally i don't use tmr1 anyway, figured i would do it to be spontanious...... on a different note i have a question about adc settings, since im running 32Mhz i set them to 32 since i seen a chart in a datasheet somewhere, what should i set it to.... i gain 50 microseconds to the loop when i use 32
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: pin c0 inop confusion
C1 is also associated with Timer1.brandonb wrote:i also tried it on c1 and it did the same thing
Thats why I believe its either internal to hardware, or a flowcode is changing a register to prevent C0 and C1 from functioning normally when timer1 is enabled?
If I find anything, I will post about it.
Martin
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: pin c0 inop confusion
weird.... can you help me understand how to set the adc parameters correctly to get best accuracy and speed for a 16f1939, not understanding the datasheet on it
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: pin c0 inop confusion
Hi Brandon.
Looking at the data sheet, TAD time FOSC/32 looks like the shortest time period you can use.
You can go in to ADC external properties set conversion speed to Fosc/32.
Then for faster speeds reduce Acquisition time.
If loop is too tight then reducing Acquisition time. too much could lead in erratic results.
I'm no expert on this, and may not even be 100% correct.
Martin
Looking at the data sheet, TAD time FOSC/32 looks like the shortest time period you can use.
You can go in to ADC external properties set conversion speed to Fosc/32.
Then for faster speeds reduce Acquisition time.
If loop is too tight then reducing Acquisition time. too much could lead in erratic results.
I'm no expert on this, and may not even be 100% correct.
Martin
Martin
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
- Contact:
Re: pin c0 inop confusion
thats what i do, when i test it its always accurate, i dont understand the frc, looking at the datasheet it would appear to set it at a max referance of 4v if used?Looking at the data sheet, TAD time FOSC/32 looks like the shortest time period you can use.
You can go in to ADC external properties set conversion speed to Fosc/32.
Then for faster speeds reduce Acquisition time
if using frc selection and have three adc's being read it takes 247.5 us, if i set 1/32 its shaves off 47 us and leaves it at 200.5us... im guessing thats probably as quick as it gets to average speed and accuracy but will play with the samples to see what i can come up with
here's a working flowchart of the first post if anyone was curious, i fixed a couple mistakes and used tmr4 without problems