|
|
View previous topic :: View next topic |
Author |
Message |
Diego López
Joined: 25 May 2012 Posts: 11 Location: Colombia
|
Memset function reset gpio PIC12F675 |
Posted: Fri May 25, 2012 10:33 am |
|
|
I do not speak English, I apologize
memset function has gpio port to zeros
Code: | set_tris_a(0b111110);
bit_set(gpio,0);
memset(dato_recibido, 0, sizeof(dato_recibido));
|
thank you very much
complete code
Code: | #include <12f675.h>
#use delay(clock=4000000, restart_wdt)
#fuses xt,wdt,brownout,put,protect,nomclr
#byte gpio = 0x05
#define led_tecla gpio,0
int dato_recibido[5];
void main() //Rutina principal
{
set_tris_a(0b111110);
bit_set(gpio,0);
memset(dato_recibido, 0, sizeof(dato_recibido));
while(true)
{
delay_ms(10);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 25, 2012 1:13 pm |
|
|
What is the problem ?
Do you think that memset() is setting the GPIO port = 0 ?
What is your CCS compiler version ? |
|
|
Diego López
Joined: 25 May 2012 Posts: 11 Location: Colombia
|
|
Posted: Fri May 25, 2012 7:54 pm |
|
|
When you run the function memset() on the PIC12F675 happens that the GPIO is set to zero.
CCS 4.130
thank you very much |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 25, 2012 11:46 pm |
|
|
I think it's a bug in memset() for the 12F-series PICs. Look at the last
post in the thread in the following link. He has the same bug.
He's using vs. 4.108.
http://www.ccsinfo.com/forum/viewtopic.php?t=43266&highlight=memset
This bug appears to start in vs. 4.033 and continue to the current
version 4.032.
You can see it in the .LST file below. The code is clearing PortA (GPIO).
Code: |
.................... bit_set(gpio,0);
0030: BCF 03.5 // Bank 0
0031: BSF 05.0
.................... memset(dato_recibido, 0, sizeof(dato_recibido));
0032: CLRF 05 // Set GPIO port = 0 *** Bug
0033: MOVLW 24
0034: MOVWF 04
0035: CLRF 20
0036: MOVLW 05
0037: MOVWF 21
0038: GOTO 004
....................
|
Here's the code for vs. 4.031. Notice that they don't call a routine at
address 0004. Instead they just clear memory in a loop. They don't
write to PortA (at address 05) and there is no bug:
Code: |
.................... bit_set(gpio,0);
0029: BCF 03.5
002A: BSF 05.0
.................... memset(dato_recibido, 0, sizeof(dato_recibido));
002B: MOVLW 05
002C: MOVWF 21
002D: INCF 22,F
002E: MOVLW 25
002F: MOVWF 04
0030: BCF 03.7
0031: CLRF 00
0032: INCF 04,F
0033: DECFSZ 21,F
0034: GOTO 031
.................... |
The memset bug appears to be confined to the 12F series. I looked at
code for 16F877 and 16F628 and I didn't see it clearing Port A.
I'll report it to CCS.
As a work-around, I suggest that you clear the array manually with
code. You can do it the same way as shown in the last post in the link,
or you could write a for() loop to do it. |
|
|
Diego López
Joined: 25 May 2012 Posts: 11 Location: Colombia
|
|
Posted: Sat May 26, 2012 10:43 am |
|
|
Thank you very much. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|